ZQuest Classic Coverage Report


Directory: src/
File: src/zc/script_drawing.cpp
Date: 2026-01-10 10:20:36
Exec Total Coverage
Lines: 1495 5761 26.0%
Functions: 54 108 50.0%
Branches: 639 2974 21.5%

Line Branch Exec Source
1 //! ritate_sprite_trans doesn't seem to be supported by or allegro header !?
2
3 //glibc 2.28 and later require this: -Z
4 #include <optional>
5 #include <utility>
6 #ifdef __GNUG__
7 #define ALLEGRO_NO_FIX_ALIASES
8 #endif
9
10 #include "base/qrs.h"
11 #include "base/dmap.h"
12 #include "base/zdefs.h"
13 #include "base/zc_alleg.h"
14 #include "zc/script_drawing.h"
15 #include "zc/rendertarget.h"
16 #include "zc/maps.h"
17 #include "tiles.h"
18 #include "zc/zelda.h"
19 #include "zc/ffscript.h"
20 #include "base/util.h"
21 #include "subscr.h"
22 #include "drawing.h"
23 #include "base/mapscr.h"
24 #include "base/misctypes.h"
25 using namespace util;
26 extern refInfo *ri;
27 extern script_bitmaps scb;
28 #include <stdio.h>
29 #include <fstream>
30
31 static int32_t secondary_draw_origin_xoff;
32 static int32_t secondary_draw_origin_yoff;
33
34 124968468 static std::optional<std::pair<int, int>> get_draw_origin_offset(DrawOrigin draw_origin, int draw_origin_target_uid, int xoff, int yoff)
35 {
36 int xoffset;
37 int yoffset;
38
2/2
✓ Branch 0 taken 41428 times.
✓ Branch 1 taken 124927040 times.
124968468 if (draw_origin == DrawOrigin::Region)
39 {
40 41428 xoffset = xoff - viewport.x;
41 41428 yoffset = yoff - viewport.y;
42 41428 }
43
2/2
✓ Branch 0 taken 8072 times.
✓ Branch 1 taken 124918968 times.
124927040 else if (draw_origin == DrawOrigin::RegionScrollingNew)
44 {
45 8072 xoffset = xoff + FFCore.ScrollingData[SCROLLDATA_NRX];
46 8072 yoffset = yoff + FFCore.ScrollingData[SCROLLDATA_NRY];
47 8072 }
48
2/2
✓ Branch 0 taken 105315950 times.
✓ Branch 1 taken 19603018 times.
124918968 else if (draw_origin == DrawOrigin::PlayingField)
49 {
50 105315950 xoffset = xoff;
51 105315950 yoffset = yoff;
52 105315950 }
53
2/2
✓ Branch 0 taken 19596907 times.
✓ Branch 1 taken 6111 times.
19603018 else if (draw_origin == DrawOrigin::Screen)
54 {
55 19596907 xoffset = 0;
56 19596907 yoffset = 0;
57 19596907 }
58
1/2
✓ Branch 0 taken 6111 times.
✗ Branch 1 not taken.
6111 else if (draw_origin == DrawOrigin::Sprite)
59 {
60 6111 sprite* draw_origin_target = sprite::getByUID(draw_origin_target_uid);
61
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6111 times.
6111 if (!draw_origin_target)
62 {
63 Z_scripterrlog("Warning: Ignoring draw command using DRAW_ORIGIN_SPRITE with non-existent sprite uid: %d.\n", draw_origin_target_uid);
64 return std::nullopt;
65 }
66
67 6111 xoffset = xoff - viewport.x + draw_origin_target->x.getInt();
68 6111 yoffset = yoff - viewport.y + draw_origin_target->y.getInt();
69 6111 }
70 else
71 {
72 // Unexpected.
73 xoffset = 0;
74 yoffset = 0;
75 }
76
77 124968468 return std::make_pair(xoffset, yoffset);
78 124968468 }
79
80 23279041 std::pair<int, bool> resolveScriptingBitmapId(int scripting_bitmap_id)
81 {
82
4/6
✓ Branch 0 taken 3396548 times.
✓ Branch 1 taken 19882493 times.
✓ Branch 2 taken 3396548 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3396548 times.
✗ Branch 5 not taken.
23279041 if ((scripting_bitmap_id % 10000 == 0) && (scripting_bitmap_id >= -20000 && scripting_bitmap_id <= 60000))
83 {
84 // Handles zscript values for RT_SCREEN, RT_BITMAP0, etc.
85 3396548 return {scripting_bitmap_id / 10000, false};
86 }
87
3/4
✓ Branch 0 taken 19882493 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11739102 times.
✓ Branch 3 taken 8143391 times.
19882493 else if (scripting_bitmap_id - 10 >= -2 && scripting_bitmap_id - 10 <= rtBMP6)
88 {
89 // Handles Game->LoadBitmapID, which sets the bitmap pointer as a "long" int.
90 8143391 return {scripting_bitmap_id - 10, false};
91 }
92 else
93 {
94 // This is a user bitmap.
95 11739102 return {scripting_bitmap_id, true};
96 }
97 23279041 }
98
99 static BITMAP* current_target_bmp;
100
101 66997310 static BITMAP* resolveScriptingBitmap(int scripting_bitmap_id)
102 {
103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66997310 times.
66997310 if (scripting_bitmap_id < 0)
104 {
105 // Handles zscript values for RT_SCREEN, etc.
106 return FFCore.GetScriptBitmap((scripting_bitmap_id / 10000) + 10, current_target_bmp);
107 }
108 else
109 {
110 // Handles Game->LoadBitmapID, which sets the bitmap pointer as a "long" int.
111 // Also handles user bitmaps.
112 66997310 return FFCore.GetScriptBitmap(scripting_bitmap_id, current_target_bmp);
113 }
114 66997310 }
115
116 inline double sd_log2( double n )
117 {
118 // log(n)/log(2) is log2.
119 double v = log( (double)n ) / log( (double)2 );
120 return v;
121 }
122
123 inline bool isPowerOfTwo(int32_t n)
124 {
125 if(n==0)
126 return false;
127
128 return (ceil(sd_log2(n)) == floor(sd_log2(n)));
129 }
130
131 BITMAP* ScriptDrawingBitmapPool::_parent_bmp = 0;
132
133 class TileHelper
134 {
135 public:
136
137 46094 static void OldPutTile(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, byte skiprows=0)
138 {
139 // Past the end of the tile page?
140
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46094 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
46094 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
141 {
142 byte w2=(tile+w)%TILES_PER_ROW;
143 OldPutTile(_Dest, tile, x, y, w-w2, h, color, flip);
144 OldPutTile(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip);
145 return;
146 }
147
148
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 46094 times.
46094 switch(flip)
149 {
150 case 1:
151 for(int32_t j=0; j<h; j++)
152 for(int32_t k=w-1; k>=0; k--)
153 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip);
154
155 break;
156
157 case 2:
158 for(int32_t j=h-1; j>=0; j--)
159 for(int32_t k=0; k<w; k++)
160 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip);
161
162 break;
163
164 case 3:
165 for(int32_t j=h-1; j>=0; j--)
166 for(int32_t k=w-1; k>=0; k--)
167 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip);
168
169 break;
170
171 46094 case 0:
172 default:
173
2/2
✓ Branch 0 taken 181240 times.
✓ Branch 1 taken 46094 times.
227334 for(int32_t j=0; j<h; j++)
174
2/2
✓ Branch 0 taken 1111148 times.
✓ Branch 1 taken 181240 times.
1292388 for(int32_t k=0; k<w; k++)
175 1292388 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip);
176
177 46094 break;
178 }
179 46094 }
180
181 4793800 static void OverTile(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, byte skiprows=0)
182 {
183 4793800 overtileblock16(_Dest,tile,x,y,w,h,color,flip,skiprows);
184 4793800 }
185
186 static void OverTileCloaked(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t flip, byte skiprows=0)
187 {
188 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
189 {
190 byte w2=(tile+w)%TILES_PER_ROW;
191 OverTileCloaked(_Dest, tile, x, y, w-w2, h, flip);
192 OverTileCloaked(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, flip);
193 return;
194 }
195
196 switch(flip)
197 {
198 case 1:
199 for(int32_t j=0; j<h; j++)
200 for(int32_t k=w-1; k>=0; k--)
201 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, flip);
202
203 break;
204
205 case 2:
206 for(int32_t j=h-1; j>=0; j--)
207 for(int32_t k=0; k<w; k++)
208 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, flip);
209
210 break;
211
212 case 3:
213 for(int32_t j=h-1; j>=0; j--)
214 for(int32_t k=w-1; k>=0; k--)
215 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, flip);
216
217 break;
218
219 default:
220 for(int32_t j=0; j<h; j++)
221 for(int32_t k=0; k<w; k++)
222 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, flip);
223
224 break;
225 }
226 }
227
228 289390 static void OverTileTranslucent(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, int32_t opacity, byte skiprows=0)
229 {
230
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 289390 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
289390 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
231 {
232 byte w2=(tile+w)%TILES_PER_ROW;
233 OverTileTranslucent(_Dest, tile, x, y, w-w2, h, color, flip, opacity);
234 OverTileTranslucent(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip, opacity);
235 return;
236 }
237
238
1/4
✓ Branch 0 taken 289390 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
289390 switch(flip)
239 {
240 case 1:
241 for(int32_t j=0; j<h; j++)
242 for(int32_t k=w-1; k>=0; k--)
243 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip, opacity);
244
245 break;
246
247 case 2:
248 for(int32_t j=h-1; j>=0; j--)
249 for(int32_t k=0; k<w; k++)
250 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip, opacity);
251
252 break;
253
254 case 3:
255 for(int32_t j=h-1; j>=0; j--)
256 for(int32_t k=w-1; k>=0; k--)
257 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip, opacity);
258
259 break;
260
261 default:
262
2/2
✓ Branch 0 taken 1672950 times.
✓ Branch 1 taken 289390 times.
1962340 for(int32_t j=0; j<h; j++)
263
2/2
✓ Branch 0 taken 23552575 times.
✓ Branch 1 taken 1672950 times.
25225525 for(int32_t k=0; k<w; k++)
264 25225525 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip, opacity);
265
266 289390 break;
267 }
268 289390 }
269
270 static void PutTileTranslucent(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, int32_t opacity, byte skiprows=0)
271 {
272 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
273 {
274 byte w2=(tile+w)%TILES_PER_ROW;
275 PutTileTranslucent(_Dest, tile, x, y, w-w2, h, color, flip, opacity);
276 PutTileTranslucent(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip, opacity);
277 return;
278 }
279
280 switch(flip)
281 {
282 case 1:
283 for(int32_t j=0; j<h; j++)
284 for(int32_t k=w-1; k>=0; k--)
285 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip, opacity);
286
287 break;
288
289 case 2:
290 for(int32_t j=h-1; j>=0; j--)
291 for(int32_t k=0; k<w; k++)
292 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip, opacity);
293
294 break;
295
296 case 3:
297 for(int32_t j=h-1; j>=0; j--)
298 for(int32_t k=w-1; k>=0; k--)
299 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip, opacity);
300
301 break;
302
303 default:
304 for(int32_t j=0; j<h; j++)
305 for(int32_t k=0; k<w; k++)
306 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip, opacity);
307
308 break;
309 }
310 }
311 };
312
313
314
315
316 3344855 void do_rectr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
317 {
318 //sdci[1]=layer
319 //sdci[2]=x
320 //sdci[3]=y
321 //sdci[4]=x2
322 //sdci[5]=y2
323 //sdci[6]=color
324 //sdci[7]=scale factor
325 //sdci[8]=rotation anchor x
326 //sdci[9]=rotation anchor y
327 //sdci[10]=rotation angle
328 //sdci[11]=fill
329 //sdci[12]=opacity
330
1/2
✓ Branch 0 taken 3344855 times.
✗ Branch 1 not taken.
3344855 if(sdci[7]==0) //scale
331 {
332 return;
333 }
334
335 3344855 int32_t x1=sdci[2]/10000;
336 3344855 int32_t y1=sdci[3]/10000;
337 3344855 int32_t x2=sdci[4]/10000;
338 3344855 int32_t y2=sdci[5]/10000;
339
340
1/2
✓ Branch 0 taken 3344855 times.
✗ Branch 1 not taken.
3344855 if(x1>x2)
341 {
342 zc_swap(x1,x2);
343 }
344
345
2/2
✓ Branch 0 taken 3325339 times.
✓ Branch 1 taken 19516 times.
3344855 if(y1>y2)
346 {
347 19516 zc_swap(y1,y2);
348 19516 }
349
350
2/2
✓ Branch 0 taken 3342035 times.
✓ Branch 1 taken 2820 times.
3344855 if(sdci[7] != 10000)
351 {
352 2820 int32_t w=x2-x1+1;
353 2820 int32_t h=y2-y1+1;
354 2820 int32_t w2=(w*sdci[7])/10000;
355 2820 int32_t h2=(h*sdci[7])/10000;
356 2820 x1=x1-((w2-w)/2);
357 2820 x2=x2+((w2-w)/2);
358 2820 y1=y1-((h2-h)/2);
359 2820 y2=y2+((h2-h)/2);
360 2820 }
361
362 3344855 int32_t color=sdci[6]/10000;
363
364
2/2
✓ Branch 0 taken 3308009 times.
✓ Branch 1 taken 36846 times.
3344855 if(sdci[12]/10000<=127) //translucent
365 {
366 36846 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
367 36846 }
368
369
2/2
✓ Branch 0 taken 82060 times.
✓ Branch 1 taken 3262795 times.
3344855 if(sdci[10]==0) //no rotation
370 {
371
2/2
✓ Branch 0 taken 838727 times.
✓ Branch 1 taken 2424068 times.
3262795 if(sdci[11]) //filled
372 {
373 2424068 rectfill(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
374 2424068 }
375 else //outline
376 {
377 838727 rect(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
378 }
379 3262795 }
380 else //rotate
381 {
382 int32_t xy[16];
383 82060 int32_t rx=sdci[8]/10000;
384 82060 int32_t ry=sdci[9]/10000;
385 82060 fixed ra1=itofix(sdci[10]%10000)/10000;
386 82060 fixed ra2=itofix(sdci[10]/10000);
387 82060 fixed ra=ra1+ra2;
388 82060 ra = (ra/360)*256;
389
390 82060 fixed fcosa = fixcos(ra);
391 82060 fixed fsina = fixsin(ra);
392
393 82060 xy[ 0]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry))); //x1
394 82060 xy[ 1]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry))); //y1
395 82060 xy[ 2]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y1 - ry))); //x2
396 82060 xy[ 3]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y1 - ry))); //y1
397 82060 xy[ 4]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry))); //x2
398 82060 xy[ 5]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry))); //y2
399 82060 xy[ 6]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y2 - ry))); //x1
400 82060 xy[ 7]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y2 - ry))); //y2
401 82060 xy[ 8]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry + 1))); //x1
402 82060 xy[ 9]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry + 1))); //y1
403 82060 xy[10]=xoffset+rx + fixtoi((fcosa * (x2 - rx - 1) - fsina * (y1 - ry))); //x2
404 82060 xy[11]=yoffset+ry + fixtoi((fsina * (x2 - rx - 1) + fcosa * (y1 - ry))); //y1
405 82060 xy[12]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry - 1))); //x2
406 82060 xy[13]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry - 1))); //y2
407 82060 xy[14]=xoffset+rx + fixtoi((fcosa * (x1 - rx + 1) - fsina * (y2 - ry))); //x1
408 82060 xy[15]=yoffset+ry + fixtoi((fsina * (x1 - rx + 1) + fcosa * (y2 - ry))); //y2
409
410
1/2
✓ Branch 0 taken 82060 times.
✗ Branch 1 not taken.
82060 if(sdci[11]) //filled
411 {
412 82060 polygon(bmp, 4, xy, color);
413 82060 }
414 else //outline
415 {
416 line(bmp, xy[0], xy[1], xy[10], xy[11], color);
417 line(bmp, xy[2], xy[3], xy[12], xy[13], color);
418 line(bmp, xy[4], xy[5], xy[14], xy[15], color);
419 line(bmp, xy[6], xy[7], xy[ 8], xy[ 9], color);
420 }
421 }
422
423 3344855 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
424 3344855 }
425
426 void do_framer(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
427 {
428 //sdci[1]=layer
429 //sdci[2]=x
430 //sdci[3]=y
431 //sdci[4]=tile
432 //sdci[5]=cset
433 //sdci[6]=width
434 //sdci[7]=height
435 //sdci[8]=overlay
436 //sdci[9]=opacity
437
438 int32_t x=sdci[2]/10000;
439 int32_t y=sdci[3]/10000;
440
441 int32_t tile=sdci[4]/10000;
442 int32_t cs=sdci[5]/10000;
443 int32_t w=sdci[6]/10000;
444 int32_t h=sdci[7]/10000;
445 bool overlay=sdci[8];
446 bool trans=(sdci[9]/10000<=127);
447
448 frame2x2(bmp, x + xoffset, y + yoffset, tile, cs, w, h, 0, overlay, trans);
449 }
450
451
452
453 1170681 void do_circler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
454 {
455 //sdci[1]=layer
456 //sdci[2]=x
457 //sdci[3]=y
458 //sdci[4]=radius
459 //sdci[5]=color
460 //sdci[6]=scale factor
461 //sdci[7]=rotation anchor x
462 //sdci[8]=rotation anchor y
463 //sdci[9]=rotation angle
464 //sdci[10]=fill
465 //sdci[11]=opacity
466
1/2
✓ Branch 0 taken 1170681 times.
✗ Branch 1 not taken.
1170681 if(sdci[6]==0) //scale
467 {
468 return;
469 }
470
471 1170681 int32_t x1=sdci[2]/10000;
472 1170681 int32_t y1=sdci[3]/10000;
473 1170681 qword r=sdci[4];
474
475
1/2
✓ Branch 0 taken 1170681 times.
✗ Branch 1 not taken.
1170681 if(sdci[6] != 10000)
476 {
477 r*=sdci[6];
478 r/=10000;
479 }
480
481 1170681 r/=10000;
482 1170681 int32_t color=sdci[5]/10000;
483
484
2/2
✓ Branch 0 taken 989374 times.
✓ Branch 1 taken 181307 times.
1170681 if(sdci[11]/10000<=127) //translucent
485 {
486 181307 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
487 181307 }
488
489
5/6
✓ Branch 0 taken 58575 times.
✓ Branch 1 taken 1112106 times.
✓ Branch 2 taken 1344 times.
✓ Branch 3 taken 57231 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1344 times.
1170681 if(sdci[9]!=0&&(sdci[2]!=sdci[7]||sdci[3]!=sdci[8])) //rotation
490 {
491 int32_t xy[2];
492 57231 int32_t rx=sdci[7]/10000;
493 57231 int32_t ry=sdci[8]/10000;
494 57231 fixed ra1=itofix(sdci[9]%10000)/10000;
495 57231 fixed ra2=itofix(sdci[9]/10000);
496 57231 fixed ra=ra1+ra2;
497 57231 ra = (ra/360)*256;
498
499 57231 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
500 57231 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
501 57231 x1=xy[0];
502 57231 y1=xy[1];
503 57231 }
504
505
2/2
✓ Branch 0 taken 1153667 times.
✓ Branch 1 taken 17014 times.
1170681 if(sdci[10]) //filled
506 {
507 1153667 circlefill(bmp, x1+xoffset, y1+yoffset, r, color);
508 1153667 }
509 else //outline
510 {
511 17014 circle(bmp, x1+xoffset, y1+yoffset, r, color);
512 }
513
514 1170681 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
515 1170681 }
516
517
518 void do_arcr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
519 {
520 //sdci[1]=layer
521 //sdci[2]=x
522 //sdci[3]=y
523 //sdci[4]=radius
524 //sdci[5]=start angle
525 //sdci[6]=end angle
526 //sdci[7]=color
527 //sdci[8]=scale factor
528 //sdci[9]=rotation anchor x
529 //sdci[10]=rotation anchor y
530 //sdci[11]=rotation angle
531 //sdci[12]=closed
532 //sdci[13]=fill
533 //sdci[14]=opacity
534
535 if(sdci[8]==0) //scale
536 {
537 return;
538 }
539
540 int32_t cx=sdci[2]/10000;
541 int32_t cy=sdci[3]/10000;
542 qword r=sdci[4];
543
544 if(sdci[8] != 10000)
545 {
546 r*=sdci[8];
547 r/=10000;
548 }
549
550 r/=10000;
551
552 int32_t color=sdci[7]/10000;
553
554 fixed ra1=itofix(sdci[11]%10000)/10000;
555 fixed ra2=itofix(sdci[11]/10000);
556 fixed ra=ra1+ra2;
557 ra = (ra/360)*256;
558
559
560 fixed a1=itofix(sdci[5]%10000)/10000;
561 fixed a2=itofix(sdci[5]/10000);
562 fixed sa=a1+a2;
563 sa = (sa/360)*256;
564
565 a1=itofix(sdci[6]%10000)/10000;
566 a2=itofix(sdci[6]/10000);
567 fixed ea=a1+a2;
568 ea = (ea/360)*256;
569
570 if(sdci[11]!=0) //rotation
571 {
572 int32_t rx=sdci[9]/10000;
573 int32_t ry=sdci[10]/10000;
574
575 cx=rx + fixtoi((fixcos(ra) * (cx - rx) - fixsin(ra) * (cy - ry))); //x1
576 cy=ry + fixtoi((fixsin(ra) * (cx - rx) + fixcos(ra) * (cy - ry))); //y1
577 ea-=ra;
578 sa-=ra;
579 }
580
581 int32_t fx=cx+fixtoi(fixcos(-(ea+sa)/2)*r/2);
582 int32_t fy=cy+fixtoi(fixsin(-(ea+sa)/2)*r/2);
583
584 if(sdci[12]) //closed
585 {
586 if(sdci[13]) //filled
587 {
588 clear_bitmap(prim_bmp);
589 arc(prim_bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
590 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
591 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
592 int fillx = zc_max(0,fx)+xoffset;
593 int filly = zc_max(0,fy)+yoffset;
594 zprint2("Screen->Arc fill at prim_bmp (%d,%d) - 512x512\n", fillx, filly);
595 floodfill(prim_bmp, fillx, filly, color);
596
597 if(sdci[14]/10000<=127) //translucent
598 {
599 draw_trans_sprite(bmp, prim_bmp, 0,0);
600 }
601 else
602 {
603 draw_sprite(bmp, prim_bmp, 0,0);
604 }
605 }
606 else
607 {
608 arc(bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
609 line(bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
610 line(bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
611 }
612 }
613 else
614 {
615 if(sdci[14]/10000<=127) //translucent
616 {
617 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
618 }
619
620 arc(bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
621 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
622 }
623 }
624
625
626 1850 void do_ellipser(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
627 {
628 //sdci[1]=layer
629 //sdci[2]=x
630 //sdci[3]=y
631 //sdci[4]=radiusx
632 //sdci[5]=radiusy
633 //sdci[6]=color
634 //sdci[7]=scale factor
635 //sdci[8]=rotation anchor x
636 //sdci[9]=rotation anchor y
637 //sdci[10]=rotation angle
638 //sdci[11]=fill
639 //sdci[12]=opacity
640
641
1/2
✓ Branch 0 taken 1850 times.
✗ Branch 1 not taken.
1850 if(sdci[7]==0) //scale
642 {
643 return;
644 }
645
646 1850 int32_t x1=sdci[2]/10000;
647 1850 int32_t y1=sdci[3]/10000;
648 1850 int32_t radx=sdci[4]/10000;
649 1850 radx*=sdci[7]/10000;
650 1850 int32_t rady=sdci[5]/10000;
651 1850 rady*=sdci[7]/10000;
652 1850 int32_t color=sdci[6]/10000;
653 1850 float rotation = sdci[10]/10000;
654
655 1850 int32_t rx=sdci[8]/10000;
656 1850 int32_t ry=sdci[9]/10000;
657 1850 fixed ra1=itofix(sdci[10]%10000)/10000;
658 1850 fixed ra2=itofix(sdci[10]/10000);
659 1850 fixed ra=ra1+ra2;
660 1850 ra = (ra/360)*256;
661
662 int32_t xy[2];
663 1850 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
664 1850 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
665 1850 x1=xy[0];
666 1850 y1=xy[1];
667
668
6/8
✓ Branch 0 taken 1746 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 1687 times.
✓ Branch 3 taken 59 times.
✓ Branch 4 taken 1687 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1687 times.
1850 if(radx<1||rady<1||radx>255||rady>255) return;
669
670 1687 BITMAP* bitty = script_drawing_commands.AquireSubBitmap(radx*2+1, rady*2+1);
671
672
2/2
✓ Branch 0 taken 1630 times.
✓ Branch 1 taken 57 times.
1687 if(sdci[11]) //filled
673 {
674
675
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 606 times.
1630 if(sdci[12]/10000<128) //translucent
676 {
677 1024 clear_bitmap(prim_bmp);
678
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
679 1024 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
680 1024 draw_trans_sprite(bmp, prim_bmp, 0, 0);
681 1024 }
682 else // no opacity
683 {
684
1/2
✓ Branch 0 taken 606 times.
✗ Branch 1 not taken.
606 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
685 606 rotate_sprite(bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
686 }
687 1630 }
688 else //not filled
689 {
690
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 43 times.
57 if(sdci[12]/10000<128) //translucent
691 {
692 14 clear_bitmap(prim_bmp);
693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
694 14 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
695 14 draw_trans_sprite(bmp, prim_bmp, 0, 0);
696 14 }
697 else // no opacity
698 {
699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
700 43 rotate_sprite(bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
701 }
702 }
703
704 // Since 0 is the transparent color, the stuff above will fail if the ellipse color is also 0.
705 // Instead, it uses color 255 and replaces it afterward. That'll also screw up color 255 around
706 // the ellipse, but it shouldn't be used anyway.
707
1/2
✓ Branch 0 taken 1687 times.
✗ Branch 1 not taken.
1687 if(color==0)
708 {
709 // This is very slow, so check the smallest possible square
710 int32_t endx=zc_min(bmp->w-1, x1+zc_max(radx, rady));
711 int32_t endy=zc_min(bmp->h-1, y1+zc_max(radx, rady));
712
713 for(int32_t y=zc_max(0, y1-zc_max(radx, rady)); y<=endy; y++)
714 for(int32_t x=zc_max(0, x1-zc_max(radx, rady)); x<=endx; x++)
715 if(getpixel(bmp, x, y)==255)
716 putpixel(bmp, x, y, 0);
717 }
718
719 1687 script_drawing_commands.ReleaseSubBitmap(bitty);
720 1850 }
721
722
723 2351475 void do_liner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
724 {
725 //sdci[1]=layer
726 //sdci[2]=x
727 //sdci[3]=y
728 //sdci[4]=x2
729 //sdci[5]=y2
730 //sdci[6]=color
731 //sdci[7]=scale factor
732 //sdci[8]=rotation anchor x
733 //sdci[9]=rotation anchor y
734 //sdci[10]=rotation angle
735 //sdci[11]=opacity
736
1/2
✓ Branch 0 taken 2351475 times.
✗ Branch 1 not taken.
2351475 if(sdci[7]==0) //scale
737 {
738 return;
739 }
740
741 2351475 int32_t x1=sdci[2]/10000;
742 2351475 int32_t y1=sdci[3]/10000;
743 2351475 int32_t x2=sdci[4]/10000;
744 2351475 int32_t y2=sdci[5]/10000;
745
746
2/2
✓ Branch 0 taken 1903153 times.
✓ Branch 1 taken 448322 times.
2351475 if(sdci[7] != 10000)
747 {
748 448322 int32_t w=x2-x1+1;
749 448322 int32_t h=y2-y1+1;
750 448322 int32_t w2=int32_t(w*((double)sdci[7]/10000.0));
751 448322 int32_t h2=int32_t(h*((double)sdci[7]/10000.0));
752 448322 x1=x1-((w2-w)/2);
753 448322 x2=x2+((w2-w)/2);
754 448322 y1=y1-((h2-h)/2);
755 448322 y2=y2+((h2-h)/2);
756 448322 }
757
758 2351475 int32_t color=sdci[6]/10000;
759
760
1/2
✓ Branch 0 taken 2351475 times.
✗ Branch 1 not taken.
2351475 if(sdci[11]/10000<=127) //translucent
761 {
762 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
763 }
764
765
2/2
✓ Branch 0 taken 939459 times.
✓ Branch 1 taken 1412016 times.
2351475 if(sdci[10]!=0) //rotation
766 {
767 int32_t xy[4];
768 1412016 int32_t rx=sdci[8]/10000;
769 1412016 int32_t ry=sdci[9]/10000;
770 1412016 fixed ra1=itofix(sdci[10]%10000)/10000;
771 1412016 fixed ra2=itofix(sdci[10]/10000);
772 1412016 fixed ra=ra1+ra2;
773
774 1412016 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
775 1412016 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
776 1412016 xy[ 2]=rx + fixtoi((fixcos(ra) * (x2 - rx) - fixsin(ra) * (y2 - ry))); //x2
777 1412016 xy[ 3]=ry + fixtoi((fixsin(ra) * (x2 - rx) + fixcos(ra) * (y2 - ry))); //y2
778 1412016 x1=xy[0];
779 1412016 y1=xy[1];
780 1412016 x2=xy[2];
781 1412016 y2=xy[3];
782 1412016 }
783
784 2351475 line(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
785 2351475 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
786 2351475 }
787
788 void do_linesr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
789 {
790 //sdci[1]=layer
791 //sdci[2]=array[10] = { x, y, x2, y2, colour, scale, rx, ry, angle, opacity }
792
793 //sdci[2]=x
794 //sdci[3]=y
795 //sdci[4]=x2
796 //sdci[5]=y2
797 //sdci[6]=color
798 //sdci[7]=scale factor
799 //sdci[8]=rotation anchor x
800 //sdci[9]=rotation anchor y
801 //sdci[10]=rotation angle
802 //sdci[11]=opacity
803 //if(sdci[7]==0) //scale
804 //{
805 // return;
806 //}
807
808 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
809
810 if(!v_ptr)
811 {
812 al_trace("Screen->PutPixels: Vector pointer is null! Internal error. \n");
813 return;
814 }
815
816 std::vector<int32_t> &v = *v_ptr;
817
818 if(v.empty())
819 return;
820
821 int32_t* pos = &v[0];
822 int32_t sz = v.size();
823
824 for ( int32_t q = 0; q < sz; q+=10 )
825 {
826
827 int32_t x1 = v.at(q);
828 //Z_scripterrlog("Lines( x1 ) is: %d\n", x1);
829 int32_t y1 = v.at(q+1);
830 //Z_scripterrlog("Lines( x2 ) is: %d\n", y1);
831 int32_t x2 = v.at(q+2);
832 //Z_scripterrlog("Lines( x2 ) is: %d\n", x2);
833 int32_t y2 = v.at(q+3);
834 //Z_scripterrlog("Lines( y2 ) is: %d\n", y2);
835 int32_t color = v.at(q+4);
836 //Z_scripterrlog("Lines( colour ) is: %d\n", color);
837 //Z_scripterrlog("Lines( scale ) is: %d\n", v.at(q+5));
838 if (v.at(q+5) == 0) { Z_scripterrlog("Lines() aborting due to scale\n"); return; }//scale
839
840 if( v.at(q+5) != 10000)
841 {
842 int32_t w=x2-x1+1;
843 int32_t h=y2-y1+1;
844 int32_t w2=int32_t(w*((double)v.at(q+5)));
845 int32_t h2=int32_t(h*((double)v.at(q+5)));
846 x1=x1-((w2-w)/2);
847 x2=x2+((w2-w)/2);
848 y1=y1-((h2-h)/2);
849 y2=y2+((h2-h)/2);
850 }
851
852
853 //Z_scripterrlog("Lines( opacity ) is: %d\n", v.at(q+9));
854 if(v.at(q+9) <= 127) //translucent
855 {
856 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
857 }
858 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
859 //Z_scripterrlog("Lines( rotation ) is: %d\n", v.at(q+8));
860 //Z_scripterrlog("Lines( rot_x ) is: %d\n", v.at(q+6));
861 //Z_scripterrlog("Lines( rot_x ) is: %d\n", v.at(q+7));
862 if( v.at(q+8) !=0 ) //rotation
863 {
864 int32_t xy[4];
865
866 int32_t rx = v.at(q+6);
867
868 int32_t ry = v.at(q+7);
869
870 fixed ra1=itofix(v.at(q+8) % 1);
871 fixed ra2=itofix(v.at(q+8));
872 fixed ra=ra1+ra2;
873
874 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
875 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
876 xy[ 2]=rx + fixtoi((fixcos(ra) * (x2 - rx) - fixsin(ra) * (y2 - ry))); //x2
877 xy[ 3]=ry + fixtoi((fixsin(ra) * (x2 - rx) + fixcos(ra) * (y2 - ry))); //y2
878 x1=xy[0];
879 y1=xy[1];
880 x2=xy[2];
881 y2=xy[3];
882 }
883 //Z_scripterrlog("Lines( xofs ) is: %d\n", xoffset);
884 //Z_scripterrlog("Lines( yofs ) is: %d\n", yoffset);
885 line(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
886 }
887 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
888 }
889
890 1080 void do_polygonr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
891 {
892 //sdci[1]=layer
893 //sdci[2]=point count
894 //sdci[3]array[]
895 //sdci[4] = colour
896 //sdci[5] = opacity
897
898 1080 int32_t col = sdci[4]/10000;
899 1080 int32_t op = sdci[5]/10000;
900
901 1080 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
902
903
1/2
✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
1080 if(!v_ptr)
904 {
905 al_trace("Screen->Polygon: Vector pointer is null! Internal error. \n");
906 return;
907 }
908
909 1080 std::vector<int32_t> &v = *v_ptr;
910
911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1080 times.
1080 if(v.empty())
912 return;
913
914 1080 int32_t* pos = &v[0];
915 1080 int32_t sz = v.size();
916 1080 int32_t numpoints = (sdci[2]/10000);
917
1/2
✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
1080 if(sz & 1) --sz; //even amount only
918
1/2
✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
1080 if(numpoints > sz/2) //cap to array
919 numpoints = sz/2;
920
1/2
✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
1080 if(numpoints < 1)
921 return; //Don't draw 0 or negative point count
922
923
2/2
✓ Branch 0 taken 6480 times.
✓ Branch 1 taken 1080 times.
7560 for (int32_t i = 0; i < sz; i += 2)
924 {
925 6480 pos[i] += xoffset;
926 6480 pos[i + 1] += yoffset;
927 6480 }
928
929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1080 times.
1080 if(op <= 127) //translucent
930 {
931 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
932 }
933 1080 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
934
935 1080 polygon(bmp, numpoints, (int32_t*)pos, col);
936 1080 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
937 1080 }
938
939 void bmp_do_polygonr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
940 {
941 //sdci[1]=layer
942 //sdci[2]=point count
943 //sdci[3]array[]
944 //sdci[4] = colour
945 //sdci[5] = opacity
946
947 int32_t col = sdci[4]/10000;
948 int32_t op = sdci[5]/10000;
949
950 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
951 {
952 Z_scripterrlog("bitmap->Polygon() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
953 return;
954 }
955 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
956 if ( refbmp == NULL ) return;
957
958 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
959
960 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
961
962 if(!v_ptr)
963 {
964 al_trace("bitmap->Polygon: Vector pointer is null! Internal error. \n");
965 return;
966 }
967
968 std::vector<int32_t> &v = *v_ptr;
969
970 if(v.empty())
971 return;
972
973 int32_t* pos = &v[0];
974 int32_t sz = v.size();
975 int32_t numpoints = (sdci[2]/10000);
976 if(sz & 1) --sz; //even amount only
977 if(numpoints > sz/2) //cap to array
978 numpoints = sz/2;
979 if(numpoints < 1)
980 return; //Don't draw 0 or negative point count
981
982 for (int32_t i = 0; i < sz; i += 2)
983 {
984 pos[i] += xoffset;
985 pos[i + 1] += yoffset;
986 }
987
988 if(op <= 127) //translucent
989 {
990 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
991 }
992 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
993
994 polygon(refbmp, numpoints, (int32_t*)pos, col);
995 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
996 }
997
998 void do_spliner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
999 {
1000 /* layer, x1, y1, x2, y2, x3, y3, x4, y4, color, opacity */
1001
1002 int32_t points[8] = { xoffset + (sdci[2]/10000), yoffset + (sdci[3]/10000),
1003 xoffset + (sdci[4]/10000), yoffset + (sdci[5]/10000),
1004 xoffset + (sdci[6]/10000), yoffset + (sdci[7]/10000),
1005 xoffset + (sdci[8]/10000), yoffset + (sdci[9]/10000)
1006 };
1007
1008 if(sdci[11]/10000 < 128) //translucent
1009 {
1010 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
1011 }
1012
1013 spline(bmp, points, sdci[10]/10000);
1014
1015 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
1016 }
1017
1018
1019 404879 void do_putpixelr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1020 {
1021 //sdci[1]=layer
1022 //sdci[2]=x
1023 //sdci[3]=y
1024 //sdci[4]=color
1025 //sdci[5]=rotation anchor x
1026 //sdci[6]=rotation anchor y
1027 //sdci[7]=rotation angle
1028 //sdci[8]=opacity
1029 404879 int32_t x1=sdci[2]/10000;
1030 404879 int32_t y1=sdci[3]/10000;
1031 404879 int32_t color=sdci[4]/10000;
1032
1033
2/2
✓ Branch 0 taken 404863 times.
✓ Branch 1 taken 16 times.
404879 if(sdci[8]/10000<=127) //translucent
1034 {
1035 16 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
1036 16 }
1037
1038
1/2
✓ Branch 0 taken 404879 times.
✗ Branch 1 not taken.
404879 if(sdci[7]!=0) //rotation
1039 {
1040 int32_t xy[2];
1041 int32_t rx=sdci[5]/10000;
1042 int32_t ry=sdci[6]/10000;
1043 fixed ra1=itofix(sdci[7]%10000)/10000;
1044 fixed ra2=itofix(sdci[7]/10000);
1045 fixed ra=ra1+ra2;
1046
1047 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
1048 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
1049 x1=xy[0];
1050 y1=xy[1];
1051 }
1052
1053 404879 putpixel(bmp, x1+xoffset, y1+yoffset, color);
1054 404879 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
1055 404879 }
1056
1057 void do_putpixelsr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1058 {
1059 //Z_scripterrlog("Starting putpixels()%s\n");
1060 //sdci[1]=layer
1061 //sdci[2]=array {x,y,colour,opacity}
1062 //sdci[3]=rotation anchor x
1063 //sdci[4]=rotation anchor y
1064 //sdci[5]=rotation angle
1065
1066
1067 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
1068
1069 if(!v_ptr)
1070 {
1071 al_trace("Screen->PutPixels: Vector pointer is null! Internal error. \n");
1072 return;
1073 }
1074
1075 std::vector<int32_t> &v = *v_ptr;
1076
1077 if(v.empty())
1078 return;
1079
1080 int32_t* pos = &v[0];
1081 int32_t sz = v.size();
1082
1083
1084 int32_t x1 = 0;
1085 int32_t y1 = 0;
1086
1087 for ( int32_t q = 0; q < sz; q+=4 )
1088 {
1089 x1 = v.at(q); //pos[q];
1090 y1 = v.at(q+1); //pos[q+1];
1091 if(sdci[5]!=0) //rotation
1092 {
1093 int32_t xy[2];
1094 int32_t rx=sdci[3]/10000;
1095 int32_t ry=sdci[4]/10000;
1096 fixed ra1=itofix(sdci[5]%10000)/10000;
1097 fixed ra2=itofix(sdci[5]/10000);
1098 fixed ra=ra1+ra2;
1099
1100 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
1101 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
1102 x1=xy[0];
1103 y1=xy[1];
1104 }
1105 if ( v.at(q+3) /*pos[q+3]*/ < 128 ) drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
1106 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
1107 putpixel(bmp, x1+xoffset, y1+yoffset, v.at(q+2) /*pos[q+2]*/);
1108 }
1109 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
1110 }
1111
1112 2302534 void do_drawtiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1113 {
1114 //sdci[1]=layer
1115 //sdci[2]=x
1116 //sdci[3]=y
1117 //sdci[4]=tile
1118 //sdci[5]=tile width
1119 //sdci[6]=tile height
1120 //sdci[7]=color (cset)
1121 //sdci[8]=scale x
1122 //sdci[9]=scale y
1123 //sdci[10]=rotation anchor x
1124 //sdci[11]=rotation anchor y
1125 //sdci[12]=rotation angle
1126 //sdci[13]=flip
1127 //sdci[14]=transparency
1128 //sdci[15]=opacity
1129
1130 2302534 int32_t w = sdci[5]/10000;
1131 2302534 int32_t h = sdci[6]/10000;
1132
1133
4/8
✓ Branch 0 taken 2302534 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2302534 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2302534 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2302534 times.
2302534 if(w < 1 || h < 1 || h > 20 || w > 20)
1134 {
1135 return;
1136 }
1137
1138 2302534 int32_t xscale=sdci[8]/10000;
1139 2302534 int32_t yscale=sdci[9]/10000;
1140 2302534 int32_t rx = sdci[10]/10000;
1141 2302534 int32_t ry = sdci[11]/10000;
1142 2302534 float rotation=sdci[12]/10000;
1143 2302534 int32_t flip=(sdci[13]/10000)&3;
1144 2302534 bool transparency=sdci[14]!=0;
1145 2302534 int32_t opacity=sdci[15]/10000;
1146 2302534 int32_t color=sdci[7]/10000;
1147
1148 2302534 int32_t x1=sdci[2]/10000;
1149 2302534 int32_t y1=sdci[3]/10000;
1150
1/2
✓ Branch 0 taken 2302534 times.
✗ Branch 1 not taken.
2302534 byte skiprows = get_qr(qr_DRAWTILE_TALL_DRAWS_WRAP_POORLY) ? 0 : h-1;
1151
1152 //don't scale if it's not safe to do so
1153 2302534 bool canscale = true;
1154
1155
3/4
✓ Branch 0 taken 2281889 times.
✓ Branch 1 taken 20645 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2281889 times.
2302534 if(xscale==0||yscale==0)
1156 {
1157 20645 return;
1158 }
1159
1160
3/4
✓ Branch 0 taken 141060 times.
✓ Branch 1 taken 2140829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 141060 times.
2281889 if(xscale<=0||yscale<=0)
1161 2140829 canscale = false; //default size
1162
1163
4/4
✓ Branch 0 taken 141060 times.
✓ Branch 1 taken 2140829 times.
✓ Branch 2 taken 140626 times.
✓ Branch 3 taken 2000203 times.
2281889 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
1164 {
1165 281686 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16);
1166
1167
1/2
✓ Branch 0 taken 281686 times.
✗ Branch 1 not taken.
281686 if(transparency) //transparency
1168 {
1169 281686 TileHelper::OverTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip, skiprows);
1170 281686 }
1171 else //no transparency
1172 {
1173 TileHelper::OldPutTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip, skiprows);
1174 }
1175
1176
2/2
✓ Branch 0 taken 144314 times.
✓ Branch 1 taken 137372 times.
281686 if(rotation != 0)
1177 {
1178 //low negative values indicate no anchor-point rotation
1179
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144314 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144314 if(rx>-777||ry>-777)
1180 {
1181 int32_t xy[2];
1182 144314 fixed ra1=itofix(sdci[12]%10000)/10000;
1183 144314 fixed ra2=itofix(sdci[12]/10000);
1184 144314 fixed ra=ra1+ra2;
1185 144314 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
1186 144314 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
1187 144314 x1=xy[0];
1188 144314 y1=xy[1];
1189 144314 }
1190
1191
2/2
✓ Branch 0 taken 3688 times.
✓ Branch 1 taken 140626 times.
144314 if(canscale) //scale first
1192 {
1193 //damnit all, .. fixme.
1194
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3688 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3688 times.
3688 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
1195 3688 clear_bitmap(tempbit);
1196
1197 3688 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
1198
1199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3688 times.
3688 if(opacity < 128)
1200 {
1201 clear_bitmap(prim_bmp);
1202 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
1203 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1204 }
1205 else
1206 {
1207 3688 rotate_sprite(bmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1208 }
1209
1210 3688 destroy_bitmap(tempbit);
1211 3688 }
1212 else //no scale
1213 {
1214
2/2
✓ Branch 0 taken 3586 times.
✓ Branch 1 taken 137040 times.
140626 if(opacity < 128)
1215 {
1216 3586 clear_bitmap(prim_bmp);
1217 3586 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
1218 3586 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1219 3586 }
1220 else
1221 {
1222 137040 rotate_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1223 }
1224 }
1225 144314 }
1226 else //scale only
1227 {
1228
1/2
✓ Branch 0 taken 137372 times.
✗ Branch 1 not taken.
137372 if(canscale)
1229 {
1230
2/2
✓ Branch 0 taken 4344 times.
✓ Branch 1 taken 133028 times.
137372 if(opacity<128)
1231 {
1232 4344 clear_bitmap(prim_bmp);
1233 4344 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
1234 4344 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1235 4344 }
1236 else
1237 {
1238 133028 stretch_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
1239 }
1240 137372 }
1241 else //error -do not scale
1242 {
1243 if(opacity<128)
1244 {
1245 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1246 }
1247 else
1248 {
1249 draw_sprite(bmp, pbitty, x1+xoffset, y1+yoffset);
1250 }
1251 }
1252 }
1253
1254 281686 script_drawing_commands.ReleaseSubBitmap(pbitty);
1255
1256 281686 }
1257 else // no scale or rotation
1258 {
1259
2/2
✓ Branch 0 taken 1972749 times.
✓ Branch 1 taken 27454 times.
2000203 if(transparency)
1260 {
1261
2/2
✓ Branch 0 taken 224767 times.
✓ Branch 1 taken 1747982 times.
1972749 if(opacity<=127)
1262 224767 TileHelper::OverTileTranslucent(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
1263 else
1264 1747982 TileHelper::OverTile(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
1265 1972749 }
1266 else
1267 {
1268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27454 times.
27454 if(opacity<=127)
1269 TileHelper::PutTileTranslucent(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
1270 else
1271 27454 TileHelper::OldPutTile(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
1272 }
1273 }
1274 2302534 }
1275
1276 void do_drawtilecloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1277 {
1278 //sdci[1]=layer
1279 //sdci[2]=x
1280 //sdci[3]=y
1281 //sdci[4]=tile
1282 //sdci[5]=tile width
1283 //sdci[6]=tile height
1284 //sdci[7]=flip
1285
1286 int32_t w = sdci[5]/10000;
1287 int32_t h = sdci[6]/10000;
1288
1289 if(w < 1 || h < 1 || h > 20 || w > 20)
1290 {
1291 return;
1292 }
1293
1294 int32_t flip=(sdci[7]/10000)&3;
1295
1296 int32_t x1=sdci[2]/10000;
1297 int32_t y1=sdci[3]/10000;
1298 byte skiprows = get_qr(qr_DRAWTILE_TALL_DRAWS_WRAP_POORLY) ? 0 : h-1;
1299
1300 TileHelper::OverTileCloaked(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, flip, skiprows);
1301 }
1302
1303
1304 2761920 void do_drawcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1305 {
1306 //sdci[1]=layer
1307 //sdci[2]=x
1308 //sdci[3]=y
1309 //sdci[4]=combo
1310 //sdci[5]=tile width
1311 //sdci[6]=tile height
1312 //sdci[7]=color (cset)
1313 //sdci[8]=scale x
1314 //sdci[9]=scale y
1315 //sdci[10]=rotation anchor x
1316 //sdci[11]=rotation anchor y
1317 //sdci[12]=rotation angle
1318 //sdci[13]=frame
1319 //sdci[14]=flip
1320 //sdci[15]=transparency
1321 //sdci[16]=opacity
1322
1323 2761920 int32_t w = sdci[5]/10000;
1324 2761920 int32_t h = sdci[6]/10000;
1325
1326
4/8
✓ Branch 0 taken 2761920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2761920 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2761920 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2761920 times.
2761920 if(w<1||h<1||h>20||w>20)
1327 {
1328 return;
1329 }
1330 2761920 int32_t cmb = (sdci[4]/10000);
1331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2761920 times.
2761920 if((unsigned)cmb >= MAXCOMBOS)
1332 {
1333 Z_scripterrlog("DrawCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
1334 return;
1335 }
1336
1337 2761920 int32_t xscale=sdci[8]/10000;
1338 2761920 int32_t yscale=sdci[9]/10000;
1339 2761920 int32_t rx = sdci[10]/10000; //these work now
1340 2761920 int32_t ry = sdci[11]/10000; //these work now
1341 2761920 float rotation=sdci[12]/10000;
1342
1343 2761920 bool transparency=sdci[15]!=0;
1344 2761920 int32_t opacity=sdci[16]/10000;
1345 2761920 int32_t color=sdci[7]/10000;
1346 2761920 int32_t x1=sdci[2]/10000;
1347 2761920 int32_t y1=sdci[3]/10000;
1348
1349 2761920 auto& c = GET_DRAWING_COMBO(cmb);
1350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2761920 times.
2761920 if(c.animflags & AF_EDITOR_ONLY) return;
1351 2761920 int frame = sdci[13] / 10000;
1352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2761920 times.
2761920 if (get_qr(qr_DRAWCOMBO_IGNORES_FRAME))
1353 2761920 frame = -1;
1354 2761920 int32_t tiletodraw = combo_tile(c, x1, y1, frame);
1355 2761920 int32_t flip = ((sdci[14]/10000) & 3) ^ c.flip;
1356 2761920 int32_t skiprows=c.skipanimy;
1357
1358
1359 //don't scale if it's not safe to do so
1360 2761920 bool canscale = true;
1361
1362
3/4
✓ Branch 0 taken 2761847 times.
✓ Branch 1 taken 73 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2761847 times.
2761920 if(xscale==0||yscale==0)
1363 {
1364 73 return;
1365 }
1366
1367
3/4
✓ Branch 0 taken 23422 times.
✓ Branch 1 taken 2738425 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23422 times.
2761847 if(xscale<=0||yscale<=0)
1368 2738425 canscale = false; //default size
1369
1370
4/4
✓ Branch 0 taken 23422 times.
✓ Branch 1 taken 2738425 times.
✓ Branch 2 taken 109319 times.
✓ Branch 3 taken 2629106 times.
2761847 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
1371 {
1372 132741 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16); //-pbitty in the hisouse. :D
1373
1374
2/2
✓ Branch 0 taken 131705 times.
✓ Branch 1 taken 1036 times.
132741 if(transparency)
1375 {
1376 131705 TileHelper::OverTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
1377 131705 }
1378 else //no transparency
1379 {
1380 1036 TileHelper::OldPutTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
1381 }
1382
1383
2/2
✓ Branch 0 taken 109537 times.
✓ Branch 1 taken 23204 times.
132741 if(rotation != 0) // rotate
1384 {
1385 //fixed point sucks ;0
1386
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 109537 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
109537 if(rx>-777||ry>-777) //set the rotation anchor and rotate around that
1387 {
1388 int32_t xy[2];
1389 109537 fixed ra1=itofix(sdci[12]%10000)/10000;
1390 109537 fixed ra2=itofix(sdci[12]/10000);
1391 109537 fixed ra=ra1+ra2;
1392 109537 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
1393 109537 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
1394 109537 x1=xy[0];
1395 109537 y1=xy[1];
1396 109537 }
1397
1398
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 109319 times.
109537 if(canscale) //scale first
1399 {
1400
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 218 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 218 times.
218 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
1401 218 clear_bitmap(tempbit);
1402
1403 218 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
1404
1405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 218 times.
218 if(opacity < 128)
1406 {
1407 clear_bitmap(prim_bmp);
1408 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
1409 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1410 }
1411 else
1412 {
1413 218 rotate_sprite(bmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1414 }
1415
1416 218 destroy_bitmap(tempbit);
1417 218 }
1418 else //no scale
1419 {
1420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109319 times.
109319 if(opacity < 128)
1421 {
1422 clear_bitmap(prim_bmp);
1423 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
1424 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1425 }
1426 else
1427 {
1428 109319 rotate_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1429 }
1430 }
1431 109537 }
1432 else //scale only
1433 {
1434
1/2
✓ Branch 0 taken 23204 times.
✗ Branch 1 not taken.
23204 if(canscale)
1435 {
1436
2/2
✓ Branch 0 taken 9395 times.
✓ Branch 1 taken 13809 times.
23204 if(opacity<128)
1437 {
1438 9395 clear_bitmap(prim_bmp);
1439 9395 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
1440 9395 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1441 9395 }
1442 else
1443 {
1444 13809 stretch_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
1445 }
1446 23204 }
1447 else //error -do not scale
1448 {
1449 if(opacity<128)
1450 {
1451 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1452 }
1453 else
1454 {
1455 draw_sprite(bmp, pbitty, x1+xoffset, y1+yoffset);
1456 }
1457 }
1458 }
1459
1460 132741 script_drawing_commands.ReleaseSubBitmap(pbitty); //rap sucks
1461 132741 }
1462 else // no scale or rotation
1463 {
1464
1/2
✓ Branch 0 taken 2629106 times.
✗ Branch 1 not taken.
2629106 if(transparency)
1465 {
1466
2/2
✓ Branch 0 taken 64341 times.
✓ Branch 1 taken 2564765 times.
2629106 if(opacity<=127)
1467 64341 TileHelper::OverTileTranslucent(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
1468 else
1469 2564765 TileHelper::OverTile(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
1470 2629106 }
1471 else
1472 {
1473 if(opacity<=127)
1474 TileHelper::PutTileTranslucent(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
1475 else
1476 TileHelper::OldPutTile(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
1477 }
1478 }
1479 2761920 }
1480
1481 void do_drawcombocloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1482 {
1483 //sdci[1]=layer
1484 //sdci[2]=x
1485 //sdci[3]=y
1486 //sdci[4]=combo
1487 //sdci[5]=tile width
1488 //sdci[6]=tile height
1489 //sdci[7]=flip
1490
1491 int32_t w = sdci[5]/10000;
1492 int32_t h = sdci[6]/10000;
1493
1494 if(w<1||h<1||h>20||w>20)
1495 {
1496 return;
1497 }
1498 int32_t cmb = (sdci[4]/10000);
1499 if((unsigned)cmb >= MAXCOMBOS)
1500 {
1501 Z_scripterrlog("DrawComboCloaked() cannot draw combo '%d', as it is out of bounds.\n", cmb);
1502 return;
1503 }
1504
1505 int32_t x1=sdci[2]/10000;
1506 int32_t y1=sdci[3]/10000;
1507
1508 auto& c = GET_DRAWING_COMBO(cmb);
1509 int32_t tiletodraw = combo_tile(c, x1, y1);
1510 if(c.animflags & AF_EDITOR_ONLY) return;
1511 int32_t flip = ((sdci[7]/10000) & 3) ^ c.flip;
1512 int32_t skiprows=c.skipanimy;
1513
1514 TileHelper::OverTileCloaked(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, flip, skiprows);
1515 }
1516
1517
1518 5327982 void do_fasttiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1519 {
1520 /* layer, x, y, tile, color opacity */
1521
1522 5327982 int32_t opacity = sdci[6]/10000;
1523 5327982 int x = xoffset+(sdci[2]/10000);
1524 5327982 int y = yoffset+(sdci[3]/10000);
1525
1526
2/2
✓ Branch 0 taken 154230 times.
✓ Branch 1 taken 5173752 times.
5327982 if(opacity < 128)
1527 154230 overtiletranslucent16(bmp, sdci[4]/10000, x, y, sdci[5]/10000, 0, opacity);
1528 else
1529 5173752 overtile16(bmp, sdci[4]/10000, x, y, sdci[5]/10000, 0);
1530 5327982 }
1531
1532 void do_fasttilesr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1533 {
1534 /* layer, x, y, tile, color opacity */
1535
1536 //sdci[1]=layer
1537 //sdci[2]=array {x,y,tile,colour,opacity}
1538
1539 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
1540
1541 if(!v_ptr)
1542 {
1543 al_trace("Screen->PutPixels: Vector pointer is null! Internal error. \n");
1544 return;
1545 }
1546
1547 std::vector<int32_t> &v = *v_ptr;
1548
1549 if(v.empty())
1550 return;
1551
1552 int32_t* pos = &v[0];
1553 int32_t sz = v.size();
1554
1555 for ( int32_t q = 0; q < sz; q+=5 )
1556 {
1557
1558 if(v.at(q+4) < 128)
1559 overtiletranslucent16(bmp, v.at(q+2), xoffset+(v.at(q)), yoffset+(v.at(q+1)), v.at(q+3), 0, v.at(q+4));
1560 else
1561 overtile16(bmp, v.at(q+2), xoffset+(v.at(q)), yoffset+(v.at(q+1)), v.at(q+3), 0);
1562 }
1563 }
1564
1565
1566
1567 30256034 void do_fastcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1568 {
1569 /* layer, x, y, tile, color opacity */
1570
1571 30256034 int32_t opacity = sdci[6] / 10000;
1572 30256034 int32_t x1 = sdci[2] / 10000;
1573 30256034 int32_t y1 = sdci[3] / 10000;
1574
1575 30256034 int32_t cmb = (sdci[4]/10000);
1576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30256034 times.
30256034 if((unsigned)cmb >= MAXCOMBOS)
1577 {
1578 Z_scripterrlog("FastCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
1579 return;
1580 }
1581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30256034 times.
30256034 if(combobuf[cmb].animflags & AF_EDITOR_ONLY) return;
1582
1583 30256034 int x = xoffset+x1;
1584 30256034 int y = yoffset+y1;
1585
1586
2/2
✓ Branch 0 taken 7829244 times.
✓ Branch 1 taken 22426790 times.
30256034 if(opacity < 128)
1587 {
1588 7829244 overcomboblocktranslucent(bmp, x, y, cmb, sdci[5]/10000, 1, 1, 128);
1589 7829244 }
1590 else
1591 {
1592 22426790 overcomboblock(bmp, x, y, cmb, sdci[5]/10000, 1, 1);
1593 }
1594 30256034 }
1595
1596 void do_fastcombosr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1597 {
1598 /* layer, x, y, combo, cset, opacity */
1599 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
1600
1601 if(!v_ptr)
1602 {
1603 al_trace("Screen->FastCombos: Vector pointer is null! Internal error. \n");
1604 return;
1605 }
1606
1607 std::vector<int32_t> &v = *v_ptr;
1608
1609 if(v.empty())
1610 return;
1611
1612 int32_t* pos = &v[0];
1613 int32_t sz = v.size();
1614
1615 for ( int32_t q = 0; q < sz; q+=5 )
1616 {
1617 auto cid = v.at(q+2);
1618 if((unsigned)(cid) >= MAXCOMBOS)
1619 {
1620 Z_scripterrlog("FastCombos() cannot draw combo '%d', as it is out of bounds.\n", v.at(q+2));
1621 continue;
1622 }
1623 if(combobuf[cid].animflags & AF_EDITOR_ONLY) continue;
1624 if(v.at(q+4) < 128)
1625 {
1626 overcomboblocktranslucent(bmp, xoffset+v.at(q), yoffset+v.at(q+1), v.at(q+2), v.at(q+3), 1, 1, 128);
1627
1628 }
1629 else
1630 {
1631 overcomboblock(bmp, xoffset+v.at(q), yoffset+v.at(q+1), v.at(q+2), v.at(q+3), 1, 1);
1632 }
1633 }
1634 }
1635
1636
1637
1638
1639 964155 void do_drawcharr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1640 {
1641 //broken 2.50.2 and earlier drawcharacter()
1642
2/2
✓ Branch 0 taken 18543 times.
✓ Branch 1 taken 945612 times.
964155 if ( get_qr(qr_BROKENCHARINTDRAWING) )
1643 {
1644 //sdci[1]=layer
1645 //sdci[2]=x
1646 //sdci[3]=y
1647 //sdci[4]=font
1648 //sdci[5]=color
1649 //sdci[6]=bg color
1650 //sdci[7]=strech x (width)
1651 //sdci[8]=stretch y (height)
1652 //sdci[9]=char
1653 //sdci[10]=opacity
1654
1655 18543 int32_t x=sdci[2]/10000;
1656 18543 int32_t y=sdci[3]/10000;
1657 18543 int32_t font_index=sdci[4]/10000;
1658 18543 int32_t color=sdci[5]/10000;
1659 18543 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1660 18543 int32_t w=sdci[7]/10000;
1661 18543 int32_t h=sdci[8]/10000;
1662 18543 char glyph=char(sdci[9]/10000);
1663 18543 int32_t opacity=sdci[10]/10000;
1664
1665 //safe check
1666
1/2
✓ Branch 0 taken 18543 times.
✗ Branch 1 not taken.
18543 if(bg_color < -1) bg_color = -1;
1667
1668
1/2
✓ Branch 0 taken 18543 times.
✗ Branch 1 not taken.
18543 if(w>512) w=512; //w=vbound(w,0,512);
1669
1670
1/2
✓ Branch 0 taken 18543 times.
✗ Branch 1 not taken.
18543 if(h>512) h=512; //h=vbound(h,0,512);
1671
1672 //undone
1673
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18543 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18543 if(w>0&&h>0)//stretch the character
1674 {
1675 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
1676
1677 if(opacity < 128)
1678 {
1679 if(w>128||h>128)
1680 {
1681 clear_bitmap(prim_bmp);
1682
1683 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1684 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
1685 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
1686 }
1687 else //this is faster
1688 {
1689 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
1690
1691 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1692 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
1693 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
1694
1695 script_drawing_commands.ReleaseSubBitmap(pbmp2);
1696 }
1697 }
1698 else // no opacity
1699 {
1700 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1701 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
1702 }
1703
1704 }
1705 else //no stretch
1706 {
1707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18543 times.
18543 if(opacity < 128)
1708 {
1709 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
1710 clear_bitmap(pbmp);
1711
1712 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1713 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
1714
1715 destroy_bitmap(pbmp);
1716 }
1717 else // no opacity
1718 {
1719 18543 textprintf_ex(bmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
1720 }
1721 }
1722 18543 }
1723
1724 else //2.53.0 fixed version and later.
1725 {
1726
1727 //sdci[1]=layer
1728 //sdci[2]=x
1729 //sdci[3]=y
1730 //sdci[4]=font
1731 //sdci[5]=color
1732 //sdci[6]=bg color
1733 //sdci[7]=strech x (width)
1734 //sdci[8]=stretch y (height)
1735 //sdci[9]=char
1736 //sdci[10]=opacity
1737
1738 945612 int32_t x=sdci[2]/10000;
1739 945612 int32_t y=sdci[3]/10000;
1740 945612 int32_t font_index=sdci[4]/10000;
1741 945612 int32_t color=sdci[5]/10000;
1742 945612 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1743 945612 int32_t w=sdci[7]/10000;
1744 945612 int32_t h=sdci[8]/10000;
1745 945612 char glyph=char(sdci[9]/10000);
1746 945612 int32_t opacity=sdci[10]/10000;
1747
1748 //safe check
1749
1/2
✓ Branch 0 taken 945612 times.
✗ Branch 1 not taken.
945612 if(bg_color < -1) bg_color = -1;
1750
1751
1/2
✓ Branch 0 taken 945612 times.
✗ Branch 1 not taken.
945612 if(w>512) w=512; //w=vbound(w,0,512);
1752
1753
1/2
✓ Branch 0 taken 945612 times.
✗ Branch 1 not taken.
945612 if(h>512) h=512; //h=vbound(h,0,512);
1754
1755 //undone
1756
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 945612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
945612 if(w>0&&h>0)//stretch the character
1757 {
1758 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
1759
1760 if(opacity < 128)
1761 {
1762 if(w>128||h>128)
1763 {
1764 clear_bitmap(prim_bmp);
1765
1766 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1767 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
1768 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
1769 }
1770 else //this is faster
1771 {
1772 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
1773
1774 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1775 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
1776 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
1777
1778 script_drawing_commands.ReleaseSubBitmap(pbmp2);
1779 }
1780 }
1781 else // no opacity
1782 {
1783 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1784 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
1785 }
1786
1787 }
1788 else //no stretch
1789 {
1790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945612 times.
945612 if(opacity < 128)
1791 {
1792 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
1793 clear_bitmap(pbmp);
1794
1795 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1796 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
1797
1798 destroy_bitmap(pbmp);
1799 }
1800 else // no opacity
1801 {
1802 945612 textprintf_ex(bmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
1803 }
1804 }
1805
1806 }
1807
1808 964155 }
1809
1810
1811 176452 void do_drawintr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1812 {
1813 //broken 2.50.2 and earlier drawinteger()
1814
2/2
✓ Branch 0 taken 72655 times.
✓ Branch 1 taken 103797 times.
176452 if ( get_qr(qr_BROKENCHARINTDRAWING) )
1815 {
1816 //sdci[1]=layer
1817 //sdci[2]=x
1818 //sdci[3]=y
1819 //sdci[4]=font
1820 //sdci[5]=color
1821 //sdci[6]=bg color
1822 //sdci[7]=strech x (width)
1823 //sdci[8]=stretch y (height)
1824 //sdci[9]=integer
1825 //sdci[10]=num decimal places
1826 //sdci[11]=opacity
1827
1828 72655 int32_t x=sdci[2]/10000;
1829 72655 int32_t y=sdci[3]/10000;
1830 72655 int32_t font_index=sdci[4]/10000;
1831 72655 int32_t color=sdci[5]/10000;
1832 72655 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1833 72655 int32_t w=sdci[7]/10000;
1834 72655 int32_t h=sdci[8]/10000;
1835 72655 int32_t decplace=sdci[10]/10000;
1836 72655 int32_t opacity=sdci[11]/10000;
1837
1838 //safe check
1839
1/2
✓ Branch 0 taken 72655 times.
✗ Branch 1 not taken.
72655 if(bg_color < -1) bg_color = -1;
1840
1841
1/2
✓ Branch 0 taken 72655 times.
✗ Branch 1 not taken.
72655 if(w>512) w=512; //w=vbound(w,0,512);
1842
1843
1/2
✓ Branch 0 taken 72655 times.
✗ Branch 1 not taken.
72655 if(h>512) h=512; //h=vbound(h,0,512);
1844
1845 char numbuf[15];
1846
1847
1/6
✓ Branch 0 taken 72655 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
72655 switch(decplace)
1848 {
1849 default:
1850 case 0:
1851 72655 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
1852 72655 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
1853
1854 case 1:
1855 //sprintf(numbuf,"%.01f",number);
1856 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
1857 break;
1858
1859 case 2:
1860 //sprintf(numbuf,"%.02f",number);
1861 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
1862 break;
1863
1864 case 3:
1865 //sprintf(numbuf,"%.03f",number);
1866 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
1867 break;
1868
1869 case 4:
1870 //sprintf(numbuf,"%.04f",number);
1871 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
1872 break;
1873 }
1874
1875
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72655 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
72655 if(w>0&&h>0)//stretch
1876 {
1877 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
1878
1879 if(opacity < 128)
1880 {
1881 if(w>128||h>128)
1882 {
1883 clear_bitmap(prim_bmp);
1884
1885 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1886 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
1887 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
1888 }
1889 else
1890 {
1891 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
1892 clear_bitmap(pbmp2);
1893
1894 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1895 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
1896 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
1897
1898 destroy_bitmap(pbmp2);
1899 }
1900 }
1901 else // no opacity
1902 {
1903 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1904 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
1905 }
1906
1907 }
1908 else //no stretch
1909 {
1910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72655 times.
72655 if(opacity < 128)
1911 {
1912 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
1913 clear_bitmap(pbmp);
1914
1915 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1916 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
1917
1918 destroy_bitmap(pbmp);
1919 }
1920 else // no opacity
1921 {
1922 72655 textout_ex(bmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
1923 }
1924 }
1925
1926 72655 }
1927
1928 else //2.53.0 fixed version and later.
1929 {
1930 //sdci[1]=layer
1931 //sdci[2]=x
1932 //sdci[3]=y
1933 //sdci[4]=font
1934 //sdci[5]=color
1935 //sdci[6]=bg color
1936 //sdci[7]=strech x (width)
1937 //sdci[8]=stretch y (height)
1938 //sdci[9]=integer
1939 //sdci[10]=num decimal places
1940 //sdci[11]=opacity
1941
1942 103797 int32_t x=sdci[2]/10000;
1943 103797 int32_t y=sdci[3]/10000;
1944 103797 int32_t font_index=sdci[4]/10000;
1945 103797 int32_t color=sdci[5]/10000;
1946 103797 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1947 103797 int32_t w=sdci[7]/10000;
1948 103797 int32_t h=sdci[8]/10000;
1949 103797 int32_t decplace=sdci[10]/10000;
1950 103797 int32_t opacity=sdci[11]/10000;
1951
1952 //safe check
1953
1/2
✓ Branch 0 taken 103797 times.
✗ Branch 1 not taken.
103797 if(bg_color < -1) bg_color = -1;
1954
1955
1/2
✓ Branch 0 taken 103797 times.
✗ Branch 1 not taken.
103797 if(w>512) w=512; //w=vbound(w,0,512);
1956
1957
1/2
✓ Branch 0 taken 103797 times.
✗ Branch 1 not taken.
103797 if(h>512) h=512; //h=vbound(h,0,512);
1958
1959 char numbuf[15];
1960
1961
1/6
✓ Branch 0 taken 103797 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
103797 switch(decplace)
1962 {
1963 default:
1964 case 0:
1965 103797 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
1966 103797 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
1967
1968 case 1:
1969 //sprintf(numbuf,"%.01f",number);
1970 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
1971 break;
1972
1973 case 2:
1974 //sprintf(numbuf,"%.02f",number);
1975 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
1976 break;
1977
1978 case 3:
1979 //sprintf(numbuf,"%.03f",number);
1980 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
1981 break;
1982
1983 case 4:
1984 //sprintf(numbuf,"%.04f",number);
1985 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
1986 break;
1987 }
1988
1989 //FONT* font=get_zc_font(sdci[4]/10000);
1990
1991
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 103797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
103797 if(w>0&&h>0)//stretch
1992 {
1993 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(get_zc_font(font_index), numbuf)+1, text_height(get_zc_font(font_index)));
1994 clear_bitmap(pbmp);
1995 //script_drawing_commands.GetSmallTextureBitmap(1,1);
1996
1997 if(opacity < 128)
1998 {
1999 if(w>128||h>128)
2000 {
2001 clear_bitmap(prim_bmp);
2002
2003 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
2004 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
2005 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
2006 }
2007 else
2008 {
2009 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
2010 clear_bitmap(pbmp2);
2011
2012 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
2013 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
2014 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
2015
2016 destroy_bitmap(pbmp2);
2017 }
2018 }
2019 else // no opacity
2020 {
2021 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
2022 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
2023 }
2024
2025 }
2026 else //no stretch
2027 {
2028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103797 times.
103797 if(opacity < 128)
2029 {
2030 FONT* font = get_zc_font(font_index);
2031 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(font, numbuf), text_height(font));
2032 clear_bitmap(pbmp);
2033
2034 textout_ex(pbmp, font, numbuf, 0, 0, color, bg_color);
2035 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
2036
2037 destroy_bitmap(pbmp);
2038 }
2039 else // no opacity
2040 {
2041 103797 textout_ex(bmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
2042 }
2043 }
2044 }
2045 176452 }
2046
2047
2048 1607511 void do_drawstringr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2049 {
2050 //sdci[1]=layer
2051 //sdci[2]=x
2052 //sdci[3]=y
2053 //sdci[4]=font
2054 //sdci[5]=color
2055 //sdci[6]=bg color
2056 //sdci[7]=format_option
2057 //sdci[8]=string
2058 //sdci[9]=opacity
2059
2060 1607511 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
2061
2062
1/2
✓ Branch 0 taken 1607511 times.
✗ Branch 1 not taken.
1607511 if(!str)
2063 {
2064 al_trace("String pointer is null! Internal error. \n");
2065 return;
2066 }
2067
2068 1607511 int32_t x=sdci[2]/10000;
2069 1607511 int32_t y=sdci[3]/10000;
2070 1607511 FONT* font=get_zc_font(sdci[4]/10000);
2071 1607511 int32_t color=sdci[5]/10000;
2072 1607511 int32_t bg_color=sdci[6]/10000; //-1 = transparent
2073 1607511 int32_t format_type=sdci[7]/10000;
2074 1607511 int32_t opacity=sdci[9]/10000;
2075 //sdci[8] not needed :)
2076
2077 //safe check
2078
1/2
✓ Branch 0 taken 1607511 times.
✗ Branch 1 not taken.
1607511 if(bg_color < -1) bg_color = -1;
2079
2080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1607511 times.
1607511 if(opacity < 128)
2081 {
2082 int32_t width=zc_min(text_length(font, str->c_str()), 512);
2083 if (width < 1) return; //SANITY -Em
2084 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
2085 clear_bitmap(pbmp);
2086 textout_ex(pbmp, font, str->c_str(), 0, 0, color, bg_color);
2087 if(format_type == 2) // right-sided text
2088 x-=width;
2089 else if(format_type == 1) // centered text
2090 x-=width/2;
2091 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
2092 destroy_bitmap(pbmp);
2093 }
2094 else // no opacity
2095 {
2096
2/2
✓ Branch 0 taken 14345 times.
✓ Branch 1 taken 1593166 times.
1607511 if(format_type == 2) // right-sided text
2097 {
2098 14345 textout_right_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
2099 14345 }
2100
2/2
✓ Branch 0 taken 725712 times.
✓ Branch 1 taken 867454 times.
1593166 else if(format_type == 1) // centered text
2101 {
2102 725712 textout_centre_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
2103 725712 }
2104 else // standard left-sided text
2105 {
2106 867454 textout_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
2107 }
2108 }
2109 1607511 }
2110
2111 201739 void do_drawstringr2(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2112 {
2113 //sdci[1]=layer
2114 //sdci[2]=x
2115 //sdci[3]=y
2116 //sdci[4]=font
2117 //sdci[5]=color
2118 //sdci[6]=bg color
2119 //sdci[7]=format_option
2120 //sdci[8]=string
2121 //sdci[9]=opacity
2122 //sdci[10]=shadowtype
2123 //sdci[11]=shadow_color
2124
2125 201739 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
2126
2127
1/2
✓ Branch 0 taken 201739 times.
✗ Branch 1 not taken.
201739 if(!str)
2128 {
2129 al_trace("String pointer is null! Internal error. \n");
2130 return;
2131 }
2132
2133 201739 int32_t x=sdci[2]/10000;
2134 201739 int32_t y=sdci[3]/10000;
2135 201739 FONT* font=get_zc_font(sdci[4]/10000);
2136 201739 int32_t color=sdci[5]/10000;
2137 201739 int32_t bg_color=sdci[6]/10000; //-1 = transparent
2138 201739 int32_t format_type=sdci[7]/10000;
2139 201739 int32_t opacity=sdci[9]/10000;
2140 201739 int32_t textstyle = sdci[10]/10000;
2141 201739 int32_t shadow_color = sdci[11]/10000;
2142 //sdci[8] not needed :)
2143
2144 //safe check
2145
1/2
✓ Branch 0 taken 201739 times.
✗ Branch 1 not taken.
201739 if(bg_color < -1) bg_color = -1;
2146
2147
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 200999 times.
201739 if(opacity < 128)
2148 {
2149
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 int32_t width=zc_min(text_length(font, str->c_str()), 512);
2150
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if (width < 1) return; //SANITY -Em
2151 740 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
2152 740 clear_bitmap(pbmp);
2153 740 textout_styled_aligned_ex(pbmp, font, str->c_str(), 0, 0, textstyle, ALIGN_LEFT, color, shadow_color, bg_color);
2154 740 textout_ex(pbmp, font, str->c_str(), 0, 0, color, bg_color);
2155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 740 times.
740 if(format_type == 2) // right-sided text
2156 x-=width;
2157
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 else if(format_type == 1) // centered text
2158 740 x-=width/2;
2159 740 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
2160 740 destroy_bitmap(pbmp);
2161 740 }
2162 else // no opacity
2163 {
2164 200999 textout_styled_aligned_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, textstyle, format_type, color, shadow_color, bg_color);
2165 }
2166 201739 }
2167
2168
2169 9266 void do_drawquadr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2170 {
2171 //sdci[1]=layer
2172 //sdci[2]=x1
2173 //sdci[3]=y1
2174 //sdci[4]=x2
2175 //sdci[5]=y2
2176 //sdci[6]=x3
2177 //sdci[7]=y3
2178 //sdci[8]=x4
2179 //sdci[9]=y4
2180 //sdci[10]=width
2181 //sdci[11]=height
2182 //sdci[12]=cset
2183 //sdci[13]=flip
2184 //sdci[14]=tile/combo
2185 //sdci[15]=polytype
2186
2187 9266 int32_t x1 = sdci[2]/10000;
2188 9266 int32_t y1 = sdci[3]/10000;
2189 9266 int32_t x2 = sdci[4]/10000;
2190 9266 int32_t y2 = sdci[5]/10000;
2191 9266 int32_t x3 = sdci[6]/10000;
2192 9266 int32_t y3 = sdci[7]/10000;
2193 9266 int32_t x4 = sdci[8]/10000;
2194 9266 int32_t y4 = sdci[9]/10000;
2195 9266 int32_t w = sdci[10]/10000;
2196 9266 int32_t h = sdci[11]/10000;
2197 9266 int32_t color = sdci[12]/10000;
2198 9266 int32_t flip=(sdci[13]/10000)&3;
2199 9266 int32_t tile = sdci[14]/10000;
2200 9266 int32_t polytype = sdci[15]/10000;
2201
2202 //todo: finish palette shading
2203 /*
2204 POLYTYPE_FLAT
2205 POLYTYPE_GCOL
2206 POLYTYPE_GRGB
2207 POLYTYPE_ATEX
2208 POLYTYPE_PTEX
2209 POLYTYPE_ATEX_MASK
2210 POLYTYPE_PTEX_MASK
2211 POLYTYPE_ATEX_LIT
2212 POLYTYPE_PTEX_LIT
2213 POLYTYPE_ATEX_MASK_LIT
2214 POLYTYPE_PTEX_MASK_LIT
2215 POLYTYPE_ATEX_TRANS
2216 POLYTYPE_PTEX_TRANS
2217 POLYTYPE_ATEX_MASK_TRANS
2218 POLYTYPE_PTEX_MASK_TRANS
2219 */
2220 9266 polytype = vbound(polytype, 0, 14);
2221
2222
2/4
✓ Branch 0 taken 9266 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9266 times.
9266 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
2223 {
2224 Z_message("Quad() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
2225 return; //non power of two error
2226 }
2227
2228 9266 int32_t tex_width = w*16;
2229 9266 int32_t tex_height = h*16;
2230
2231 BITMAP *tex;
2232
2233 9266 bool mustDestroyBmp = false;
2234
2235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9266 times.
9266 if ( tile > 65519 ) tex = zscriptDrawingRenderTarget->GetBitmapPtr(tile - 65519);
2236 9266 else tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
2237
2238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9266 times.
9266 if(!tex)
2239 {
2240 mustDestroyBmp = true;
2241 tex = create_bitmap_ex(8, tex_width, tex_height);
2242 clear_bitmap(tex);
2243 }
2244
2245 int32_t col[4];
2246 /*
2247 if( color < 0 )
2248 {
2249 col[0]=draw_container.color_buffer[0];
2250 col[1]=draw_container.color_buffer[1];
2251 col[2]=draw_container.color_buffer[2];
2252 col[3]=draw_container.color_buffer[3];
2253 }
2254 else */
2255 {
2256 9266 col[0]=col[1]=col[2]=col[3]=color;
2257 }
2258
2259
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9266 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9266 if(tile > 0 && tile <= 65519) // TILE
2260 {
2261 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
2262 }
2263
2264
1/2
✓ Branch 0 taken 9266 times.
✗ Branch 1 not taken.
9266 if ( tile < 0 ) // COMBO
2265 {
2266 9266 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
2267 9266 const int32_t tiletodraw = combo_tile(c, x1, y1);
2268 9266 flip = flip ^ c.flip;
2269
2270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9266 times.
9266 if(!(c.animflags & AF_EDITOR_ONLY))
2271 9266 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
2272 9266 }
2273
2274 9266 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
2275 9266 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(tex_height), col[1] };
2276 9266 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(tex_width), static_cast<float>(tex_height), col[2] };
2277 9266 V3D_f V4 = { static_cast<float>(x4+xoffset), static_cast<float>(y4+yoffset), 0, static_cast<float>(tex_width), 0, col[3] };
2278
2279 9266 quad3d_f(bmp, polytype, tex, &V1, &V2, &V3, &V4);
2280
2281
1/2
✓ Branch 0 taken 9266 times.
✗ Branch 1 not taken.
9266 if(mustDestroyBmp)
2282 destroy_bitmap(tex);
2283
2284 9266 }
2285
2286
2287 void do_drawtriangler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2288 {
2289 //sdci[1]=layer
2290 //sdci[2]=x1
2291 //sdci[3]=y1
2292 //sdci[4]=x2
2293 //sdci[5]=y2
2294 //sdci[6]=x3
2295 //sdci[7]=y3
2296 //sdci[8]=width
2297 //sdci[9]=height
2298 //sdci[10]=cset
2299 //sdci[11]=flip
2300 //sdci[12]=tile/combo
2301 //sdci[13]=polytype
2302
2303 int32_t x1 = sdci[2]/10000;
2304 int32_t y1 = sdci[3]/10000;
2305 int32_t x2 = sdci[4]/10000;
2306 int32_t y2 = sdci[5]/10000;
2307 int32_t x3 = sdci[6]/10000;
2308 int32_t y3 = sdci[7]/10000;
2309 int32_t w = sdci[8]/10000;
2310 int32_t h = sdci[9]/10000;
2311 int32_t color = sdci[10]/10000;
2312 int32_t flip=(sdci[11]/10000)&3;
2313 int32_t tile = sdci[12]/10000;
2314 int32_t polytype = sdci[13]/10000;
2315
2316 polytype = vbound(polytype, 0, 14);
2317
2318 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
2319 {
2320 Z_message("Quad() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
2321 return; //non power of two error
2322 }
2323
2324 int32_t tex_width = w*16;
2325 int32_t tex_height = h*16;
2326
2327 bool mustDestroyBmp = false;
2328 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
2329
2330 if(!tex)
2331 {
2332 mustDestroyBmp = true;
2333 tex = create_bitmap_ex(8, tex_width, tex_height);
2334 clear_bitmap(tex);
2335 }
2336
2337 int32_t col[3];
2338 /*
2339 if( color < 0 )
2340 {
2341 col[0]=draw_container.color_buffer[0];
2342 col[1]=draw_container.color_buffer[1];
2343 col[2]=draw_container.color_buffer[2];
2344 }
2345 else */
2346 {
2347 col[0]=col[1]=col[2]=color;
2348 }
2349
2350 if(tile > 0) // TILE
2351 {
2352 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
2353 }
2354 else // COMBO
2355 {
2356 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
2357 const int32_t tiletodraw = combo_tile(c, x1, y1);
2358 flip = flip ^ c.flip;
2359
2360 if(!(c.animflags & AF_EDITOR_ONLY))
2361 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
2362 }
2363
2364 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
2365 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(tex_height), col[1] };
2366 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(tex_width), static_cast<float>(tex_height), col[2] };
2367
2368
2369 triangle3d_f(bmp, polytype, tex, &V1, &V2, &V3);
2370
2371 if(mustDestroyBmp)
2372 destroy_bitmap(tex);
2373 }
2374
2375
2376 937483 void do_drawbitmapr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2377 {
2378 //sdci[1]=layer
2379 //sdci[2]=bitmap
2380 //sdci[3]=sourcex
2381 //sdci[4]=sourcey
2382 //sdci[5]=sourcew
2383 //sdci[6]=sourceh
2384 //sdci[7]=destx
2385 //sdci[8]=desty
2386 //sdci[9]=destw
2387 //sdci[10]=desth
2388 //sdci[11]=rotation
2389 //sdci[12]=mask
2390
2391 937483 int32_t bitmapIndex = sdci[2]/10000;
2392 937483 int32_t sx = sdci[3]/10000;
2393 937483 int32_t sy = sdci[4]/10000;
2394 937483 int32_t sw = sdci[5]/10000;
2395 937483 int32_t sh = sdci[6]/10000;
2396 937483 int32_t dx = sdci[7]/10000;
2397 937483 int32_t dy = sdci[8]/10000;
2398 937483 int32_t dw = sdci[9]/10000;
2399 937483 int32_t dh = sdci[10]/10000;
2400 937483 float rot = sdci[11]/10000;
2401 937483 bool masked = (sdci[12] != 0);
2402
2403 //bugfix
2404 937483 sx = vbound(sx, 0, 512);
2405 937483 sy = vbound(sy, 0, 512);
2406 937483 sw = vbound(sw, 0, 512 - sx); //keep the w/h within range as well
2407 937483 sh = vbound(sh, 0, 512 - sy);
2408
2409
2410
2/4
✓ Branch 0 taken 937483 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 937483 times.
937483 if(sx >= ZScriptDrawingRenderTarget::BitmapWidth || sy >= ZScriptDrawingRenderTarget::BitmapHeight)
2411 return;
2412
2413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 937483 times.
937483 bool stretched = (sw != dw || sh != dh);
2414
2415 937483 BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
2416
2417
1/2
✓ Branch 0 taken 937483 times.
✗ Branch 1 not taken.
937483 if(!sourceBitmap)
2418 {
2419 Z_message("Warning: Screen->DrawBitmap(%d) contains invalid data or is not initialized.\n", bitmapIndex);
2420 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
2421 return;
2422 }
2423
2424 937483 BITMAP* subBmp = 0;
2425
2426
1/2
✓ Branch 0 taken 937483 times.
✗ Branch 1 not taken.
937483 if(rot != 0)
2427 {
2428 subBmp = script_drawing_commands.AquireSubBitmap(dw, dh);
2429
2430 if(!subBmp)
2431 {
2432 Z_scripterrlog("DrawBitmap() failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
2433 return;
2434 }
2435 }
2436
2437
2438 937483 dx = dx + xoffset;
2439 937483 dy = dy + yoffset;
2440
2441
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 937243 times.
937483 if(stretched)
2442 {
2443
1/2
✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
240 if(masked)
2444 {
2445
1/2
✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
240 if(rot != 0)
2446 {
2447 //if ( rot == 4096 ) { //translucent
2448 // masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2449 // //rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2450 // draw_trans_sprite(bmp, subBmp, dx, dy);
2451 // //draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, 0);
2452
2453
2454 // }
2455 //else {
2456 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2457 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2458 //rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2459 //
2460
2461 // }
2462 }
2463 else
2464 240 masked_stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
2465 240 }
2466 else
2467 {
2468 if(rot != 0)
2469 {
2470 //if ( rot == 4096 ) { //translucent
2471 // stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2472 // draw_trans_sprite(bmp, subBmp, dx, dy);
2473 // }
2474 //else {
2475 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2476 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2477 // }
2478 }
2479 else
2480 stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
2481 }
2482 240 }
2483 else
2484 {
2485
2/2
✓ Branch 0 taken 929755 times.
✓ Branch 1 taken 7488 times.
937243 if(masked)
2486 {
2487
1/2
✓ Branch 0 taken 929755 times.
✗ Branch 1 not taken.
929755 if(rot != 0)
2488 {
2489 //if ( rot == 4096 ) {//translucent
2490 // masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2491 //rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2492
2493 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2494 //rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2495 // draw_trans_sprite(bmp, subBmp, dx, dy);
2496 // }
2497 //else {
2498 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2499 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2500 // }
2501 }
2502 else
2503 929755 masked_blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
2504 929755 }
2505 else
2506 {
2507
1/2
✓ Branch 0 taken 7488 times.
✗ Branch 1 not taken.
7488 if(rot != 0)
2508 {
2509 //if ( rot == 4096 ) { //translucent
2510 // blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2511 // draw_trans_sprite(bmp, subBmp, dx, dy);
2512 // }
2513 //else {
2514 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2515 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2516 // }
2517 }
2518 else
2519 7488 blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
2520 }
2521 }
2522
2523 //cleanup
2524
1/2
✓ Branch 0 taken 937483 times.
✗ Branch 1 not taken.
937483 if(subBmp)
2525 {
2526 script_drawing_commands.ReleaseSubBitmap(subBmp);
2527 }
2528 937483 }
2529
2530
2531 //Draw]()
2532 void do_drawbitmapexr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2533 {
2534 /*
2535 //sdci[1]=layer
2536 //sdci[2]=bitmap
2537 //sdci[3]=sourcex
2538 //sdci[4]=sourcey
2539 //sdci[5]=sourcew
2540 //sdci[6]=sourceh
2541 //sdci[7]=destx
2542 //sdci[8]=desty
2543 //sdci[9]=destw
2544 //sdci[10]=desth
2545 //sdci[11]=rotation/angle
2546 //scdi[12] = pivot cx
2547 //sdci[13] = pivot cy
2548 //scdi[14] = effect flags
2549
2550
2551 const int32_t BITDX_NORMAL = 0;
2552 const int32_t BITDX_TRANS = 1; //Translucent
2553 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
2554 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
2555 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
2556 //Note: Some modes cannot be combined. if a combination is not supported, an error
2557 // detailing this will be shown in allegro.log.
2558
2559 //scdi[15] = litcolour
2560 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
2561 /not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2562
2563 //sdci[16]=mask
2564
2565 */
2566
2567 int32_t bitmapIndex = sdci[2]/10000;
2568 int32_t sx = sdci[3]/10000;
2569 int32_t sy = sdci[4]/10000;
2570 int32_t sw = sdci[5]/10000;
2571 int32_t sh = sdci[6]/10000;
2572 int32_t dx = sdci[7]/10000;
2573 int32_t dy = sdci[8]/10000;
2574 int32_t dw = sdci[9]/10000;
2575 int32_t dh = sdci[10]/10000;
2576 float rot = sdci[11]/10000;
2577 int32_t cx = sdci[12]/10000;
2578 int32_t cy = sdci[13]/10000;
2579 int32_t mode = sdci[14]/10000;
2580 int32_t litcolour = sdci[15]/10000;
2581 bool masked = (sdci[16] != 0);
2582
2583
2584
2585 //bugfix
2586 sx = vbound(sx, 0, 512);
2587 sy = vbound(sy, 0, 512);
2588 sw = vbound(sw, 0, 512 - sx); //keep the w/h within range as well
2589 sh = vbound(sh, 0, 512 - sy);
2590
2591
2592 if(sx >= ZScriptDrawingRenderTarget::BitmapWidth || sy >= ZScriptDrawingRenderTarget::BitmapHeight)
2593 return;
2594
2595 bool stretched = (sw != dw || sh != dh);
2596
2597 BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
2598
2599 if(!sourceBitmap)
2600 {
2601 Z_message("Warning: Screen->DrawBitmap(%d) contains invalid data or is not initialized.\n", bitmapIndex);
2602 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
2603 return;
2604 }
2605
2606 BITMAP* subBmp = 0;
2607
2608 /*
2609 if ( bitmapIndex == -1 ) {
2610 blit(bmp, sourceBitmap, sx, sy, 0, 0, dw, dh);
2611 }
2612 */
2613
2614 if(rot != 0 || mode != 0)
2615 {
2616 subBmp = script_drawing_commands.AquireSubBitmap(dw, dh);
2617
2618 if(!subBmp)
2619 {
2620 Z_scripterrlog("bitmap->Blit failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
2621 return;
2622 }
2623 }
2624
2625
2626 dx = dx + xoffset;
2627 dy = dy + yoffset;
2628
2629 if(stretched)
2630 {
2631 if(masked) //stretched and masked
2632 {
2633 if ( rot == 0 ) //if not rotated
2634 {
2635 switch(mode)
2636 {
2637 case 1:
2638 //transparent
2639 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2640 draw_trans_sprite(bmp, subBmp, dx, dy);
2641 break;
2642
2643
2644 case 2:
2645 //pivot?
2646 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2647 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2648 //Pivoting requires two more args
2649 break;
2650
2651 case 3:
2652 //pivot + trans
2653 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2654 pivot_sprite_trans(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2655 break;
2656
2657 case 4:
2658 //flip v
2659 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2660 draw_sprite_v_flip(bmp, subBmp, dx, dy);
2661 break;
2662
2663 case 5:
2664 //trans + v flip
2665 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2666 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
2667 break;
2668
2669 case 6:
2670 //pivot + v flip
2671 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2672 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2673 break;
2674
2675 case 8:
2676 //vlip h
2677 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2678 draw_sprite_h_flip(bmp, subBmp, dx, dy);
2679 break;
2680
2681 case 9:
2682 //trans + h flip
2683 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2684 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
2685 break;
2686
2687 case 10:
2688 //flip H and pivot
2689 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
2690 //return error cannot pivot and h flip
2691 break;
2692
2693 case 12:
2694 //vh flip
2695 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2696 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
2697 break;
2698
2699 case 13:
2700 //trans + vh flip
2701 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2702 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
2703 break;
2704
2705 case 14:
2706 //pivot and vh flip
2707 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
2708 //return error cannot both pivot and vh flip
2709 break;
2710
2711 case 16:
2712 //lit
2713 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2714 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
2715 break;
2716
2717 case 18:
2718 //pivot, lit
2719 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2720 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
2721 break;
2722
2723 case 20:
2724 //lit + v flip
2725 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2726 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
2727 break;
2728
2729 case 22:
2730 //Pivot, vflip, lit
2731 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2732 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
2733 break;
2734
2735 case 24:
2736 //lit + h flip
2737 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2738 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
2739 break;
2740
2741 case 26:
2742 //pivot + lit + hflip
2743 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
2744 //return error cannot pivot, lit, and flip
2745 break;
2746
2747 case 28:
2748 //lit + vh flip
2749 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2750 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
2751 break;
2752
2753 case 32: //gouraud
2754 //Probably not wort supporting.
2755 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2756 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
2757 break;
2758
2759 case 0:
2760 //no effect
2761 masked_stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
2762 break;
2763
2764
2765 default:
2766 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
2767
2768
2769 }
2770 } //end if not rotated
2771
2772 if ( rot != 0 ) //if rotated
2773 {
2774 switch(mode)
2775 {
2776 case 1:
2777 //transparent
2778 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2779 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2780
2781 break;
2782
2783 case 2:
2784 //pivot?
2785 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
2786 //return an error, cannot both rotate and pivot
2787 break;
2788
2789 case 3:
2790 //pivot + trans
2791 //return an error, cannot both rotate and pivot
2792 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
2793 break;
2794
2795 case 4:
2796 //flip v
2797 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2798 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2799 break;
2800
2801 case 5:
2802 //trans + v flip
2803 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2804 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2805 break;
2806
2807 case 6:
2808 //pivot + v flip
2809 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
2810 //return an error, cannot both rotate and pivot
2811 break;
2812
2813 case 8:
2814 //flip h
2815 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
2816 //return an error, cannot both rotate and flip H
2817 break;
2818
2819 case 9:
2820 //trans + h flip
2821 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
2822 //return an error, cannot rotate and flip a trans sprite
2823 break;
2824
2825 case 10:
2826 //flip H and pivot
2827 //return error cannot pivot and h flip
2828 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
2829 break;
2830
2831 case 12:
2832 //vh flip
2833 //return an error, cannot rotate and VH flip a trans sprite
2834 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
2835 break;
2836
2837 case 13:
2838 //trans + vh flip
2839 //return an error, cannot rotate and VH flip a trans sprite
2840 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
2841 break;
2842
2843 case 14:
2844 //pivot and vh flip
2845 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
2846 //return error cannot both pivot and vh flip
2847 break;
2848
2849 case 16:
2850 //lit
2851 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2852 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
2853 break;
2854
2855 case 18:
2856 //pivot, lit
2857 //return an error, cannot both rotate and pivot
2858 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
2859 break;
2860
2861 case 20:
2862 //lit + vflip
2863 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2864 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
2865 break;
2866
2867 case 22:
2868 //Pivot, vflip, lit
2869 //return an error, cannot both rotate and pivot
2870 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
2871 break;
2872
2873 case 24:
2874 //lit + h flip
2875 //return an error, cannot both rotate and H flip
2876 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
2877 break;
2878
2879 case 26:
2880 //pivot + lit + hflip
2881 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
2882 //return error cannot pivot, lit, and flip
2883 break;
2884
2885 case 28:
2886 //lit + vh flip
2887 //return an error, cannot both rotate and VH flip
2888 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
2889 break;
2890
2891 case 32: //gouraud
2892 //Probably not wort supporting.
2893 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2894 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
2895 break;
2896
2897 case 0:
2898 //no effect.
2899 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2900 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2901 break;
2902
2903 default:
2904 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
2905
2906 }
2907 }
2908 } //end if stretched and masked
2909
2910 else //stretched, not masked
2911 {
2912 if ( rot == 0 ) //if not rotated
2913 {
2914 switch(mode) {
2915 case 1:
2916 //transparent
2917 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2918 draw_trans_sprite(bmp, subBmp, dx, dy);
2919 break;
2920
2921
2922 case 2:
2923 //pivot?
2924 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2925 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2926 //Pivoting requires two more args
2927 break;
2928
2929 case 3:
2930 //pivot + trans
2931 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2932 pivot_sprite_trans(bmp, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot));
2933 break;
2934
2935 case 4:
2936 //flip v
2937 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2938 draw_sprite_v_flip(bmp, subBmp, dx, dy);
2939 break;
2940
2941 case 5:
2942 //trans + v flip
2943 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2944 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
2945 break;
2946
2947 case 6:
2948 //pivot + v flip
2949 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2950 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2951 break;
2952
2953 case 8:
2954 //vlip h
2955 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2956 draw_sprite_h_flip(bmp, subBmp, dx, dy);
2957 break;
2958
2959 case 9:
2960 //trans + h flip
2961 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2962 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
2963 break;
2964
2965 case 10:
2966 //flip H and pivot
2967 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
2968 //return error cannot pivot and h flip
2969 break;
2970
2971 case 12:
2972 //vh flip
2973 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2974 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
2975 break;
2976
2977 case 13:
2978 //trans + vh flip
2979 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2980 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
2981 break;
2982
2983 case 14:
2984 //pivot and vh flip
2985 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
2986 //return error cannot both pivot and vh flip
2987 break;
2988
2989 case 16:
2990 //lit
2991 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2992 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
2993 break;
2994
2995 case 18:
2996 //pivot, lit
2997 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2998 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
2999 break;
3000
3001 case 20:
3002 //lit + v flip
3003 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3004 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
3005 break;
3006
3007 case 22:
3008 //Pivot, vflip, lit
3009 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3010 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3011 break;
3012
3013 case 24:
3014 //lit + h flip
3015 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3016 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
3017 break;
3018
3019 case 26:
3020 //pivot + lit + hflip
3021 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
3022 //return error cannot pivot, lit, and flip
3023 break;
3024
3025 case 28:
3026 //lit + vh flip
3027 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3028 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
3029 break;
3030
3031 case 32: //gouraud
3032 //Probably not wort supporting.
3033 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3034 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3035 break;
3036
3037 case 0:
3038 //no effect
3039 stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
3040 break;
3041
3042
3043 default:
3044 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3045
3046
3047 }
3048 } //end if not rotated
3049
3050 if ( rot != 0 ) //if rotated
3051 {
3052 switch(mode)
3053 {
3054 case 1:
3055 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
3056 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3057
3058 break;
3059
3060 case 2:
3061 //pivot?
3062 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3063 //return an error, cannot both rotate and pivot
3064 break;
3065
3066 case 3:
3067 //pivot + trans
3068 //return an error, cannot both rotate and pivot
3069 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3070 break;
3071
3072 case 4:
3073 //flip v
3074 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3075 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3076 break;
3077
3078 case 5:
3079 //trans + v flip
3080 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3081 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3082 break;
3083
3084 case 6:
3085 //pivot + v flip
3086 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3087 //return an error, cannot both rotate and pivot
3088 break;
3089
3090 case 8:
3091 //flip h
3092 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
3093 //return an error, cannot both rotate and flip H
3094 break;
3095
3096 case 9:
3097 //trans + h flip
3098 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
3099 //return an error, cannot rotate and flip a trans sprite
3100 break;
3101
3102 case 10:
3103 //flip H and pivot
3104 //return error cannot pivot and h flip
3105 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3106 break;
3107
3108 case 12:
3109 //vh flip
3110 //return an error, cannot rotate and VH flip a trans sprite
3111 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3112 break;
3113
3114 case 13:
3115 //trans + vh flip
3116 //return an error, cannot rotate and VH flip a trans sprite
3117 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3118 break;
3119
3120 case 14:
3121 //pivot and vh flip
3122 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3123 //return error cannot both pivot and vh flip
3124 break;
3125
3126 case 16:
3127 //lit
3128 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
3129 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3130 break;
3131
3132 case 18:
3133 //pivot, lit
3134 //return an error, cannot both rotate and pivot
3135 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3136 break;
3137
3138 case 20:
3139 //lit + vflip
3140 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
3141 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3142 break;
3143
3144 case 22:
3145 //Pivot, vflip, lit
3146 //return an error, cannot both rotate and pivot
3147 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3148 break;
3149
3150 case 24:
3151 //lit + h flip
3152 //return an error, cannot both rotate and H flip
3153 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
3154 break;
3155
3156 case 26:
3157 //pivot + lit + hflip
3158 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
3159 //return error cannot pivot, lit, and flip
3160 break;
3161
3162 case 28:
3163 //lit + vh flip
3164 //return an error, cannot both rotate and VH flip
3165 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3166 break;
3167
3168 case 32: //gouraud
3169 //Probably not wort supporting.
3170 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3171 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3172 break;
3173
3174 case 0:
3175 //no effect.
3176 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3177 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3178 break;
3179
3180 default:
3181 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3182
3183 }
3184 }
3185
3186 } //end if stretched, but not masked
3187 }
3188 else //not stretched
3189 {
3190
3191 if(masked) //if masked, but not stretched
3192 {
3193
3194 if ( rot == 0 ) //if not rotated
3195 {
3196 switch(mode)
3197 {
3198 case 1:
3199 //transparent
3200 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3201 draw_trans_sprite(bmp, subBmp, dx, dy);
3202 break;
3203
3204
3205 case 2:
3206 //pivot?
3207 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3208 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3209 //Pivoting requires two more args
3210 break;
3211
3212 case 3:
3213 //pivot + trans
3214 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3215 pivot_sprite_trans(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3216 break;
3217
3218 case 4:
3219 //flip v
3220 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3221 draw_sprite_v_flip(bmp, subBmp, dx, dy);
3222 break;
3223
3224 case 5:
3225 //trans + v flip
3226 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3227 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
3228 break;
3229
3230 case 6:
3231 //pivot + v flip
3232 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3233 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3234 break;
3235
3236 case 8:
3237 //vlip h
3238 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3239 draw_sprite_h_flip(bmp, subBmp, dx, dy);
3240 break;
3241
3242 case 9:
3243 //trans + h flip
3244 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3245 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
3246 break;
3247
3248 case 10:
3249 //flip H and pivot
3250 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3251 //return error cannot pivot and h flip
3252 break;
3253
3254 case 12:
3255 //vh flip
3256 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3257 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
3258 break;
3259
3260 case 13:
3261 //trans + vh flip
3262 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3263 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
3264 break;
3265
3266 case 14:
3267 //pivot and vh flip
3268 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3269 //return error cannot both pivot and vh flip
3270 break;
3271
3272 case 16:
3273 //lit
3274 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3275 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
3276 break;
3277
3278 case 18:
3279 //pivot, lit
3280 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3281 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3282 break;
3283
3284 case 20:
3285 //lit + v flip
3286 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3287 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
3288 break;
3289
3290 case 22:
3291 //Pivot, vflip, lit
3292 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3293 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3294 break;
3295
3296 case 24:
3297 //lit + h flip
3298 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3299 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
3300 break;
3301
3302 case 26:
3303 //pivot + lit + hflip
3304 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
3305 //return error cannot pivot, lit, and flip
3306 break;
3307
3308 case 28:
3309 //lit + vh flip
3310 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3311 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
3312 break;
3313
3314 case 32: //gouraud
3315 //Probably not wort supporting.
3316 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3317 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3318 break;
3319
3320 case 0:
3321 //no effect
3322 masked_blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
3323 break;
3324
3325
3326 default:
3327 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3328
3329
3330 }
3331 } //end if not rotated
3332
3333 if ( rot != 0 ) //if rotated
3334 {
3335 switch(mode)
3336 {
3337 case 1:
3338 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); //transparent
3339 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3340
3341 break;
3342
3343 case 2:
3344 //pivot?
3345 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3346 //return an error, cannot both rotate and pivot
3347 break;
3348
3349 case 3:
3350 //pivot + trans
3351 //return an error, cannot both rotate and pivot
3352 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3353 break;
3354
3355 case 4:
3356 //flip v
3357 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3358 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3359 break;
3360
3361 case 5:
3362 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip
3363 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3364 break;
3365
3366 case 6:
3367 //pivot + v flip
3368 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3369 //return an error, cannot both rotate and pivot
3370 break;
3371
3372 case 8:
3373 //flip h
3374 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
3375 //return an error, cannot both rotate and flip H
3376 break;
3377
3378 case 9:
3379 //trans + h flip
3380 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
3381 //return an error, cannot rotate and flip a trans sprite
3382 break;
3383
3384 case 10:
3385 //flip H and pivot
3386 //return error cannot pivot and h flip
3387 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3388 break;
3389
3390 case 12:
3391 //vh flip
3392 //return an error, cannot rotate and VH flip a trans sprite
3393 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3394 break;
3395
3396 case 13:
3397 //trans + vh flip
3398 //return an error, cannot rotate and VH flip a trans sprite
3399 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3400 break;
3401
3402 case 14:
3403 //pivot and vh flip
3404 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3405 //return error cannot both pivot and vh flip
3406 break;
3407
3408 case 16:
3409 //lit
3410 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3411 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3412 break;
3413
3414 case 18:
3415 //pivot, lit
3416 //return an error, cannot both rotate and pivot
3417 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3418 break;
3419
3420 case 20:
3421 //lit + vflip
3422 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3423 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3424 break;
3425
3426 case 22:
3427 //Pivot, vflip, lit
3428 //return an error, cannot both rotate and pivot
3429 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3430 break;
3431
3432 case 24:
3433 //lit + h flip
3434 //return an error, cannot both rotate and H flip
3435 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
3436 break;
3437
3438 case 26:
3439 //pivot + lit + hflip
3440 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
3441 //return error cannot pivot, lit, and flip
3442 break;
3443
3444 case 28:
3445 //lit + vh flip
3446 //return an error, cannot both rotate and VH flip
3447 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3448 break;
3449
3450 case 32: //gouraud
3451 //Probably not wort supporting.
3452 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3453 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3454 break;
3455
3456 case 0:
3457 //no effect.
3458 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3459 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3460 break;
3461
3462 default:
3463 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3464
3465 }
3466 } //end rtated, masked
3467 } //end if masked
3468
3469 else //not masked, and not stretched; just blit
3470 {
3471
3472 if ( rot == 0 ) //if not rotated
3473 {
3474 switch(mode)
3475 {
3476 case 1:
3477 //transparent
3478 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3479 draw_trans_sprite(bmp, subBmp, dx, dy);
3480 break;
3481
3482
3483 case 2:
3484 //pivot?
3485 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3486 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3487 //Pivoting requires two more args
3488 break;
3489
3490 case 3:
3491 //pivot + trans
3492 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3493 pivot_sprite_trans(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3494 break;
3495
3496 case 4:
3497 //flip v
3498 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3499 draw_sprite_v_flip(bmp, subBmp, dx, dy);
3500 break;
3501
3502 case 5:
3503 //trans + v flip
3504 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3505 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
3506 break;
3507
3508 case 6:
3509 //pivot + v flip
3510 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3511 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3512 break;
3513
3514 case 8:
3515 //vlip h
3516 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3517 draw_sprite_h_flip(bmp, subBmp, dx, dy);
3518 break;
3519
3520 case 9:
3521 //trans + h flip
3522 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3523 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
3524 break;
3525
3526 case 10:
3527 //flip H and pivot
3528 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3529 //return error cannot pivot and h flip
3530 break;
3531
3532 case 12:
3533 //vh flip
3534 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3535 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
3536 break;
3537
3538 case 13:
3539 //trans + vh flip
3540 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3541 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
3542 break;
3543
3544 case 14:
3545 //pivot and vh flip
3546 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3547 //return error cannot both pivot and vh flip
3548 break;
3549
3550 case 16:
3551 //lit
3552 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3553 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
3554 break;
3555
3556 case 18:
3557 //pivot, lit
3558 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3559 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3560 break;
3561
3562 case 20:
3563 //lit + v flip
3564 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3565 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
3566 break;
3567
3568 case 22:
3569 //Pivot, vflip, lit
3570 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3571 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3572 break;
3573
3574 case 24:
3575 //lit + h flip
3576 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3577 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
3578 break;
3579
3580 case 26:
3581 //pivot + lit + hflip
3582 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
3583 //return error cannot pivot, lit, and flip
3584 break;
3585
3586 case 28:
3587 //lit + vh flip
3588 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3589 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
3590 break;
3591
3592 case 32: //gouraud
3593 //Probably not wort supporting.
3594 //blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3595 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3596 break;
3597
3598 case 0:
3599 //no effect
3600 blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
3601 break;
3602
3603
3604 default:
3605 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3606
3607
3608 }
3609 } //end if not rotated
3610
3611 if ( rot != 0 ) //if rotated
3612 {
3613 switch(mode)
3614 {
3615 case 1:
3616 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);//transparent
3617 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3618
3619 break;
3620
3621 case 2:
3622 //pivot?
3623 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3624 //return an error, cannot both rotate and pivot
3625 break;
3626
3627 case 3:
3628 //pivot + trans
3629 //return an error, cannot both rotate and pivot
3630 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3631 break;
3632
3633 case 4:
3634 //flip v
3635 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3636 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3637 break;
3638
3639 case 5:
3640 //trans + v flip
3641 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3642 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3643 break;
3644
3645 case 6:
3646 //pivot + v flip
3647 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3648 //return an error, cannot both rotate and pivot
3649 break;
3650
3651 case 8:
3652 //flip h
3653 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
3654 //return an error, cannot both rotate and flip H
3655 break;
3656
3657 case 9:
3658 //trans + h flip
3659 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
3660 //return an error, cannot rotate and flip a trans sprite
3661 break;
3662
3663 case 10:
3664 //flip H and pivot
3665 //return error cannot pivot and h flip
3666 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3667 break;
3668
3669 case 12:
3670 //vh flip
3671 //return an error, cannot rotate and VH flip a trans sprite
3672 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3673 break;
3674
3675 case 13:
3676 //trans + vh flip
3677 //return an error, cannot rotate and VH flip a trans sprite
3678 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3679 break;
3680
3681 case 14:
3682 //pivot and vh flip
3683 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3684 //return error cannot both pivot and vh flip
3685 break;
3686
3687 case 16:
3688 //lit
3689 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3690 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3691 break;
3692
3693 case 18:
3694 //pivot, lit
3695 //return an error, cannot both rotate and pivot
3696 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3697 break;
3698
3699 case 20:
3700 //lit + vflip
3701 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3702 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3703 break;
3704
3705 case 22:
3706 //Pivot, vflip, lit
3707 //return an error, cannot both rotate and pivot
3708 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3709 break;
3710
3711 case 24:
3712 //lit + h flip
3713 //return an error, cannot both rotate and H flip
3714 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
3715 break;
3716
3717 case 26:
3718 //pivot + lit + hflip
3719 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
3720 //return error cannot pivot, lit, and flip
3721 break;
3722
3723 case 28:
3724 //lit + vh flip
3725 //return an error, cannot both rotate and VH flip
3726 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3727 break;
3728
3729 case 32: //gouraud
3730 //Probably not wort supporting.
3731 //blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3732 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3733 break;
3734
3735 case 0:
3736 //no effect.
3737 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3738 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3739 break;
3740
3741 default:
3742 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3743
3744 }
3745 } //end if rotated
3746 } //end if not masked
3747 } //end if not stretched
3748
3749 //cleanup
3750 if(subBmp)
3751 {
3752 script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap.
3753 }
3754 }
3755
3756
3757 void do_drawquad3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
3758 {
3759 //sdci[1]=layer
3760 //sdci[2]=pos[12]
3761 //sdci[3]=uv[8]
3762 //sdci[4]=color[4]
3763 //sdci[5]=size[2]
3764 //sdci[6]=flip
3765 //sdci[7]=tile/combo
3766 //sdci[8]=polytype
3767
3768 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
3769
3770 if(!v_ptr)
3771 {
3772 al_trace("Quad3d: Vector pointer is null! Internal error. \n");
3773 return;
3774 }
3775
3776 std::vector<int32_t> &v = *v_ptr;
3777
3778 if(v.empty())
3779 return;
3780
3781 int32_t* pos = &v[0];
3782 int32_t* uv = &v[12];
3783 int32_t* col = &v[20];
3784 int32_t* size = &v[24];
3785
3786 int32_t w = size[0]; //magic numerical constants... yuck.
3787 int32_t h = size[1];
3788 int32_t flip = (sdci[6]/10000)&3;
3789 int32_t tile = sdci[7]/10000;
3790 int32_t polytype = sdci[8]/10000;
3791
3792 polytype = vbound(polytype, 0, 14);
3793
3794 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
3795 {
3796 Z_message("Quad3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
3797 return; //non power of two error
3798 }
3799
3800 int32_t tex_width = w*16;
3801 int32_t tex_height = h*16;
3802
3803 bool mustDestroyBmp = false;
3804 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
3805
3806 if(!tex)
3807 {
3808 mustDestroyBmp = true;
3809 tex = create_bitmap_ex(8, tex_width, tex_height);
3810 clear_bitmap(tex);
3811 }
3812
3813 if(tile > 0) // TILE
3814 {
3815 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
3816 }
3817 else // COMBO
3818 {
3819 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
3820 const int32_t tiletodraw = combo_tile(c, 0, 0);
3821 flip = flip ^ c.flip;
3822
3823 if(!(c.animflags & AF_EDITOR_ONLY))
3824 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
3825 }
3826
3827 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
3828 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
3829 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
3830 V3D_f V4 = { static_cast<float>(pos[9]+xoffset), static_cast<float>(pos[10]+yoffset), static_cast<float>(pos[11]), static_cast<float>(uv[6]), static_cast<float>(uv[7]), col[3] };
3831
3832 quad3d_f(bmp, polytype, tex, &V1, &V2, &V3, &V4);
3833
3834 if(mustDestroyBmp)
3835 destroy_bitmap(tex);
3836
3837 }
3838
3839
3840
3841 void do_drawtriangle3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
3842 {
3843 //sdci[1]=layer
3844 //sdci[2]=pos[9]
3845 //sdci[3]=uv[6]
3846 //sdci[4]=color[3]
3847 //sdci[5]=size[2]
3848 //sdci[6]=flip
3849 //sdci[7]=tile/combo
3850 //sdci[8]=polytype
3851
3852 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
3853
3854 if(!v_ptr)
3855 {
3856 al_trace("Triange3d: Vector pointer is null! Internal error. \n");
3857 return;
3858 }
3859
3860 std::vector<int32_t> &v = *v_ptr;
3861
3862 if(v.empty())
3863 return;
3864
3865 int32_t* pos = &v[0];
3866 int32_t* uv = &v[9];
3867 int32_t* col = &v[15];
3868 int32_t* size = &v[18];
3869
3870 int32_t w = size[0]; //magic numerical constants... yuck.
3871 int32_t h = size[1];
3872 int32_t flip = (sdci[6]/10000)&3;
3873 int32_t tile = sdci[7]/10000;
3874 int32_t polytype = sdci[8]/10000;
3875
3876 polytype = vbound(polytype, 0, 14);
3877
3878 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
3879 {
3880 Z_message("Triangle3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
3881 return; //non power of two error
3882 }
3883
3884 int32_t tex_width = w*16;
3885 int32_t tex_height = h*16;
3886
3887 bool mustDestroyBmp = false;
3888 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
3889
3890 if(!tex)
3891 {
3892 mustDestroyBmp = true;
3893 tex = create_bitmap_ex(8, tex_width, tex_height);
3894 clear_bitmap(tex);
3895 }
3896
3897 if(tile > 0) // TILE
3898 {
3899 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
3900 }
3901 else // COMBO
3902 {
3903 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
3904 const int32_t tiletodraw = combo_tile(c, 0, 0);
3905 flip = flip ^ c.flip;
3906
3907 if(!(c.animflags & AF_EDITOR_ONLY))
3908 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
3909 }
3910
3911 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
3912 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
3913 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
3914
3915 triangle3d_f(bmp, polytype, tex, &V1, &V2, &V3);
3916
3917 if(mustDestroyBmp)
3918 destroy_bitmap(tex);
3919
3920 }
3921
3922 12431 void bmp_do_rectr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
3923 {
3924 //Z_scripterrlog("rect sdci[13] is: %d\n", sdci[13]);
3925 //sdci[1]=layer
3926 //sdci[2]=x
3927 //sdci[3]=y
3928 //sdci[4]=x2
3929 //sdci[5]=y2
3930 //sdci[6]=color
3931 //sdci[7]=scale factor
3932 //sdci[8]=rotation anchor x
3933 //sdci[9]=rotation anchor y
3934 //sdci[10]=rotation angle
3935 //sdci[11]=fill
3936 //sdci[12]=opacity
3937 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
3938
1/2
✓ Branch 0 taken 12431 times.
✗ Branch 1 not taken.
12431 if(sdci[7]==0) //scale
3939 {
3940 return;
3941 }
3942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12431 times.
12431 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
3943 {
3944 Z_scripterrlog("bitmap->Rectangle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
3945 return;
3946 }
3947 12431 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
3948
1/2
✓ Branch 0 taken 12431 times.
✗ Branch 1 not taken.
12431 if ( refbmp == NULL ) return;
3949
3950
2/4
✓ Branch 0 taken 12431 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12431 times.
12431 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
3951
3952 12431 int32_t x1=sdci[2]/10000;
3953 12431 int32_t y1=sdci[3]/10000;
3954 12431 int32_t x2=sdci[4]/10000;
3955 12431 int32_t y2=sdci[5]/10000;
3956
3957
3958
2/2
✓ Branch 0 taken 12427 times.
✓ Branch 1 taken 4 times.
12431 if(x1>x2)
3959 {
3960 4 zc_swap(x1,x2);
3961 4 }
3962
3963
2/2
✓ Branch 0 taken 11147 times.
✓ Branch 1 taken 1284 times.
12431 if(y1>y2)
3964 {
3965 1284 zc_swap(y1,y2);
3966 1284 }
3967
3968
2/2
✓ Branch 0 taken 11151 times.
✓ Branch 1 taken 1280 times.
12431 if(sdci[7] != 10000)
3969 {
3970 1280 int32_t w=x2-x1+1;
3971 1280 int32_t h=y2-y1+1;
3972 1280 int32_t w2=(w*sdci[7])/10000;
3973 1280 int32_t h2=(h*sdci[7])/10000;
3974 1280 x1=x1-((w2-w)/2);
3975 1280 x2=x2+((w2-w)/2);
3976 1280 y1=y1-((h2-h)/2);
3977 1280 y2=y2+((h2-h)/2);
3978 1280 }
3979
3980 12431 int32_t color=sdci[6]/10000;
3981
3982
2/2
✓ Branch 0 taken 12303 times.
✓ Branch 1 taken 128 times.
12431 if(sdci[12]/10000<=127) //translucent
3983 {
3984 128 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
3985 128 }
3986
3987
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 12335 times.
12431 if(sdci[10]==0) //no rotation
3988 {
3989
2/2
✓ Branch 0 taken 9143 times.
✓ Branch 1 taken 3192 times.
12335 if(sdci[11]) //filled
3990 {
3991 9143 rectfill(refbmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
3992 9143 }
3993 else //outline
3994 {
3995 3192 rect(refbmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
3996 }
3997 12335 }
3998 else //rotate
3999 {
4000 int32_t xy[16];
4001 96 int32_t rx=sdci[8]/10000;
4002 96 int32_t ry=sdci[9]/10000;
4003 96 fixed ra1=itofix(sdci[10]%10000)/10000;
4004 96 fixed ra2=itofix(sdci[10]/10000);
4005 96 fixed ra=ra1+ra2;
4006 96 ra = (ra/360)*256;
4007
4008 96 fixed fcosa = fixcos(ra);
4009 96 fixed fsina = fixsin(ra);
4010
4011 96 xy[ 0]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry))); //x1
4012 96 xy[ 1]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry))); //y1
4013 96 xy[ 2]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y1 - ry))); //x2
4014 96 xy[ 3]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y1 - ry))); //y1
4015 96 xy[ 4]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry))); //x2
4016 96 xy[ 5]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry))); //y2
4017 96 xy[ 6]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y2 - ry))); //x1
4018 96 xy[ 7]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y2 - ry))); //y2
4019 96 xy[ 8]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry + 1))); //x1
4020 96 xy[ 9]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry + 1))); //y1
4021 96 xy[10]=xoffset+rx + fixtoi((fcosa * (x2 - rx - 1) - fsina * (y1 - ry))); //x2
4022 96 xy[11]=yoffset+ry + fixtoi((fsina * (x2 - rx - 1) + fcosa * (y1 - ry))); //y1
4023 96 xy[12]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry - 1))); //x2
4024 96 xy[13]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry - 1))); //y2
4025 96 xy[14]=xoffset+rx + fixtoi((fcosa * (x1 - rx + 1) - fsina * (y2 - ry))); //x1
4026 96 xy[15]=yoffset+ry + fixtoi((fsina * (x1 - rx + 1) + fcosa * (y2 - ry))); //y2
4027
4028
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(sdci[11]) //filled
4029 {
4030 96 polygon(refbmp, 4, xy, color);
4031 96 }
4032 else //outline
4033 {
4034 line(refbmp, xy[0], xy[1], xy[10], xy[11], color);
4035 line(refbmp, xy[2], xy[3], xy[12], xy[13], color);
4036 line(refbmp, xy[4], xy[5], xy[14], xy[15], color);
4037 line(refbmp, xy[6], xy[7], xy[ 8], xy[ 9], color);
4038 }
4039 }
4040
4041 12431 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4042 12431 }
4043
4044 void bmp_do_framer(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4045 {
4046 //sdci[1]=layer
4047 //sdci[2]=x
4048 //sdci[3]=y
4049 //sdci[4]=tile
4050 //sdci[5]=cset
4051 //sdci[6]=width
4052 //sdci[7]=height
4053 //sdci[8]=overlay
4054 //sdci[9]=opacity
4055
4056 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4057 {
4058 Z_scripterrlog("bitmap->DrawFrame() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4059 return;
4060 }
4061 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4062 if ( refbmp == NULL ) return;
4063
4064 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4065
4066 int32_t x=sdci[2]/10000;
4067 int32_t y=sdci[3]/10000;
4068
4069 int32_t tile=sdci[4]/10000;
4070 int32_t cs=sdci[5]/10000;
4071 int32_t w=sdci[6]/10000;
4072 int32_t h=sdci[7]/10000;
4073 bool overlay=sdci[8];
4074 bool trans=(sdci[9]/10000<=127);
4075
4076 frame2x2(refbmp, x + xoffset, y + yoffset, tile, cs, w, h, 0, overlay, trans);
4077 }
4078
4079
4080 192290 void bmp_do_circler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4081 {
4082 //sdci[1]=layer
4083 //sdci[2]=x
4084 //sdci[3]=y
4085 //sdci[4]=radius
4086 //sdci[5]=color
4087 //sdci[6]=scale factor
4088 //sdci[7]=rotation anchor x
4089 //sdci[8]=rotation anchor y
4090 //sdci[9]=rotation angle
4091 //sdci[10]=fill
4092 //sdci[11]=opacity
4093 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4094
1/2
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
192290 if(sdci[6]==0) //scale
4095 {
4096 return;
4097 }
4098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192290 times.
192290 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4099 {
4100 Z_scripterrlog("bitmap->Circle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4101 return;
4102 }
4103 192290 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4104
1/2
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
192290 if ( refbmp == NULL ) return;
4105
4106
2/4
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 192290 times.
192290 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4107
4108 192290 int32_t x1=sdci[2]/10000;
4109 192290 int32_t y1=sdci[3]/10000;
4110 192290 qword r=sdci[4];
4111
4112
1/2
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
192290 if(sdci[6] != 10000)
4113 {
4114 r*=sdci[6];
4115 r/=10000;
4116 }
4117
4118 192290 r/=10000;
4119 192290 int32_t color=sdci[5]/10000;
4120
4121
1/2
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
192290 if(sdci[11]/10000<=127) //translucent
4122 {
4123 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4124 }
4125
4126
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 192290 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
192290 if(sdci[9]!=0&&(sdci[2]!=sdci[7]||sdci[3]!=sdci[8])) //rotation
4127 {
4128 int32_t xy[2];
4129 int32_t rx=sdci[7]/10000;
4130 int32_t ry=sdci[8]/10000;
4131 fixed ra1=itofix(sdci[9]%10000)/10000;
4132 fixed ra2=itofix(sdci[9]/10000);
4133 fixed ra=ra1+ra2;
4134 ra = (ra/360)*256;
4135
4136 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4137 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4138 x1=xy[0];
4139 y1=xy[1];
4140 }
4141
4142
1/2
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
192290 if(sdci[10]) //filled
4143 {
4144 192290 circlefill(refbmp, x1+xoffset, y1+yoffset, r, color);
4145 192290 }
4146 else //outline
4147 {
4148 circle(refbmp, x1+xoffset, y1+yoffset, r, color);
4149 }
4150
4151 192290 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4152 192290 }
4153
4154
4155 void bmp_do_arcr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4156 {
4157 //sdci[1]=layer
4158 //sdci[2]=x
4159 //sdci[3]=y
4160 //sdci[4]=radius
4161 //sdci[5]=start angle
4162 //sdci[6]=end angle
4163 //sdci[7]=color
4164 //sdci[8]=scale factor
4165 //sdci[9]=rotation anchor x
4166 //sdci[10]=rotation anchor y
4167 //sdci[11]=rotation angle
4168 //sdci[12]=closed
4169 //sdci[13]=fill
4170 //sdci[14]=opacity
4171 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4172
4173 if(sdci[8]==0) //scale
4174 {
4175 return;
4176 }
4177 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4178 {
4179 Z_scripterrlog("bitmap->Arc() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4180 return;
4181 }
4182 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4183 if ( refbmp == NULL ) return;
4184
4185 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4186
4187 int32_t cx=sdci[2]/10000;
4188 int32_t cy=sdci[3]/10000;
4189 qword r=sdci[4];
4190
4191 if(sdci[8] != 10000)
4192 {
4193 r*=sdci[8];
4194 r/=10000;
4195 }
4196
4197 r/=10000;
4198
4199 int32_t color=sdci[7]/10000;
4200
4201 fixed ra1=itofix(sdci[11]%10000)/10000;
4202 fixed ra2=itofix(sdci[11]/10000);
4203 fixed ra=ra1+ra2;
4204 ra = (ra/360)*256;
4205
4206
4207 fixed a1=itofix(sdci[5]%10000)/10000;
4208 fixed a2=itofix(sdci[5]/10000);
4209 fixed sa=a1+a2;
4210 sa = (sa/360)*256;
4211
4212 a1=itofix(sdci[6]%10000)/10000;
4213 a2=itofix(sdci[6]/10000);
4214 fixed ea=a1+a2;
4215 ea = (ea/360)*256;
4216
4217 if(sdci[11]!=0) //rotation
4218 {
4219 int32_t rx=sdci[9]/10000;
4220 int32_t ry=sdci[10]/10000;
4221
4222 cx=rx + fixtoi((fixcos(ra) * (cx - rx) - fixsin(ra) * (cy - ry))); //x1
4223 cy=ry + fixtoi((fixsin(ra) * (cx - rx) + fixcos(ra) * (cy - ry))); //y1
4224 ea-=ra;
4225 sa-=ra;
4226 }
4227
4228 int32_t fx=cx+fixtoi(fixcos(-(ea+sa)/2)*r/2);
4229 int32_t fy=cy+fixtoi(fixsin(-(ea+sa)/2)*r/2);
4230
4231 if(sdci[12]) //closed
4232 {
4233 if(sdci[13]) //filled
4234 {
4235 clear_bitmap(prim_bmp);
4236 arc(prim_bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
4237 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
4238 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
4239 int fillx = zc_max(0,fx)+xoffset;
4240 int filly = zc_max(0,fy)+yoffset;
4241 zprint2("bitmap->Arc fill at prim_bmp (%d,%d) - 512x512\n", fillx, filly);
4242 floodfill(prim_bmp, fillx, filly, color);
4243
4244 if(sdci[14]/10000<=127) //translucent
4245 {
4246 draw_trans_sprite(refbmp, prim_bmp, 0,0);
4247 }
4248 else
4249 {
4250 draw_sprite(refbmp, prim_bmp, 0,0);
4251 }
4252 }
4253 else
4254 {
4255 arc(refbmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
4256 line(refbmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
4257 line(refbmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
4258 }
4259 }
4260 else
4261 {
4262 if(sdci[14]/10000<=127) //translucent
4263 {
4264 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4265 }
4266
4267 arc(refbmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
4268 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4269 }
4270 }
4271
4272
4273 502 void bmp_do_ellipser(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4274 {
4275 //sdci[1]=layer
4276 //sdci[2]=x
4277 //sdci[3]=y
4278 //sdci[4]=radiusx
4279 //sdci[5]=radiusy
4280 //sdci[6]=color
4281 //sdci[7]=scale factor
4282 //sdci[8]=rotation anchor x
4283 //sdci[9]=rotation anchor y
4284 //sdci[10]=rotation angle
4285 //sdci[11]=fill
4286 //sdci[12]=opacity
4287 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4288
4289
1/2
✓ Branch 0 taken 502 times.
✗ Branch 1 not taken.
502 if(sdci[7]==0) //scale
4290 {
4291 return;
4292 }
4293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 502 times.
502 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4294 {
4295 Z_scripterrlog("bitmap->Ellipse() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4296 return;
4297 }
4298 502 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4299
1/2
✓ Branch 0 taken 502 times.
✗ Branch 1 not taken.
502 if ( refbmp == NULL ) return;
4300
4301 502 int32_t x1=sdci[2]/10000;
4302 502 int32_t y1=sdci[3]/10000;
4303 502 int32_t radx=sdci[4]/10000;
4304 502 radx*=sdci[7]/10000;
4305 502 int32_t rady=sdci[5]/10000;
4306 502 rady*=sdci[7]/10000;
4307 502 int32_t color=sdci[6]/10000;
4308 502 float rotation = sdci[10]/10000;
4309
4310 502 int32_t rx=sdci[8]/10000;
4311 502 int32_t ry=sdci[9]/10000;
4312 502 fixed ra1=itofix(sdci[10]%10000)/10000;
4313 502 fixed ra2=itofix(sdci[10]/10000);
4314 502 fixed ra=ra1+ra2;
4315 502 ra = (ra/360)*256;
4316
4317
2/4
✓ Branch 0 taken 502 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 502 times.
✗ Branch 3 not taken.
502 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4318
4319 int32_t xy[2];
4320 502 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4321 502 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4322 502 x1=xy[0];
4323 502 y1=xy[1];
4324
4325
6/8
✓ Branch 0 taken 498 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 494 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 494 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 494 times.
502 if(radx<1||rady<1||radx>255||rady>255) return;
4326
4327 494 BITMAP* bitty = script_drawing_commands.AquireSubBitmap(radx*2+1, rady*2+1);
4328
4329
2/4
✓ Branch 0 taken 494 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 494 times.
494 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4330
4331
1/2
✓ Branch 0 taken 494 times.
✗ Branch 1 not taken.
494 if(sdci[11]) //filled
4332 {
4333
4334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 494 times.
494 if(sdci[12]/10000<128) //translucent
4335 {
4336 clear_bitmap(prim_bmp);
4337 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
4338 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4339 draw_trans_sprite(refbmp, prim_bmp, 0, 0);
4340 }
4341 else // no opacity
4342 {
4343
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 62 times.
494 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
4344 494 rotate_sprite(refbmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4345 }
4346 494 }
4347 else //not filled
4348 {
4349 if(sdci[12]/10000<128) //translucent
4350 {
4351 clear_bitmap(prim_bmp);
4352 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
4353 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4354 draw_trans_sprite(refbmp, prim_bmp, 0, 0);
4355 }
4356 else // no opacity
4357 {
4358 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
4359 rotate_sprite(refbmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4360 }
4361 }
4362
4363 // Since 0 is the transparent color, the stuff above will fail if the ellipse color is also 0.
4364 // Instead, it uses color 255 and replaces it afterward. That'll also screw up color 255 around
4365 // the ellipse, but it shouldn't be used anyway.
4366
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 62 times.
494 if(color==0)
4367 {
4368 // This is very slow, so check the smallest possible square
4369
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 62 times.
62 int32_t endx=zc_min(bmp->w-1, x1+zc_max(radx, rady));
4370
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 62 times.
62 int32_t endy=zc_min(bmp->h-1, y1+zc_max(radx, rady));
4371
4372
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 60 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 4430 times.
✓ Branch 7 taken 62 times.
4492 for(int32_t y=zc_max(0, y1-zc_max(radx, rady)); y<=endy; y++)
4373
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 4430 times.
✓ Branch 2 taken 1086 times.
✓ Branch 3 taken 3344 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1086 times.
✓ Branch 6 taken 467774 times.
✓ Branch 7 taken 4430 times.
472204 for(int32_t x=zc_max(0, x1-zc_max(radx, rady)); x<=endx; x++)
4374
2/2
✓ Branch 0 taken 238992 times.
✓ Branch 1 taken 228782 times.
696556 if(getpixel(refbmp, x, y)==255)
4375 233212 putpixel(refbmp, x, y, 0);
4376 62 }
4377
4378 494 script_drawing_commands.ReleaseSubBitmap(bitty);
4379 502 }
4380
4381
4382 144 void bmp_do_liner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4383 {
4384 //sdci[1]=layer
4385 //sdci[2]=x
4386 //sdci[3]=y
4387 //sdci[4]=x2
4388 //sdci[5]=y2
4389 //sdci[6]=color
4390 //sdci[7]=scale factor
4391 //sdci[8]=rotation anchor x
4392 //sdci[9]=rotation anchor y
4393 //sdci[10]=rotation angle
4394 //sdci[11]=opacity
4395 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4396
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[7]==0) //scale
4397 {
4398 return;
4399 }
4400
4401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4402 {
4403 Z_scripterrlog("bitmap->Line() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4404 return;
4405 }
4406
4407 144 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4408
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if ( refbmp == NULL ) return;
4409
4410 144 int32_t x1=sdci[2]/10000;
4411 144 int32_t y1=sdci[3]/10000;
4412 144 int32_t x2=sdci[4]/10000;
4413 144 int32_t y2=sdci[5]/10000;
4414
4415
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[7] != 10000)
4416 {
4417 int32_t w=x2-x1+1;
4418 int32_t h=y2-y1+1;
4419 int32_t w2=int32_t(w*((double)sdci[7]/10000.0));
4420 int32_t h2=int32_t(h*((double)sdci[7]/10000.0));
4421 x1=x1-((w2-w)/2);
4422 x2=x2+((w2-w)/2);
4423 y1=y1-((h2-h)/2);
4424 y2=y2+((h2-h)/2);
4425 }
4426
4427 144 int32_t color=sdci[6]/10000;
4428
4429
2/4
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144 times.
144 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4430
4431
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[11]/10000<=127) //translucent
4432 {
4433 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4434 }
4435
4436
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[10]!=0) //rotation
4437 {
4438 int32_t xy[4];
4439 int32_t rx=sdci[8]/10000;
4440 int32_t ry=sdci[9]/10000;
4441 fixed ra1=itofix(sdci[10]%10000)/10000;
4442 fixed ra2=itofix(sdci[10]/10000);
4443 fixed ra=ra1+ra2;
4444
4445 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4446 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4447 xy[ 2]=rx + fixtoi((fixcos(ra) * (x2 - rx) - fixsin(ra) * (y2 - ry))); //x2
4448 xy[ 3]=ry + fixtoi((fixsin(ra) * (x2 - rx) + fixcos(ra) * (y2 - ry))); //y2
4449 x1=xy[0];
4450 y1=xy[1];
4451 x2=xy[2];
4452 y2=xy[3];
4453 }
4454
4455 144 line(refbmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
4456 144 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4457 144 }
4458
4459
4460 void bmp_do_spliner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4461 {
4462 /* layer, x1, y1, x2, y2, x3, y3, x4, y4, color, opacity */
4463 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4464
4465 int32_t points[8] = { xoffset + (sdci[2]/10000), yoffset + (sdci[3]/10000),
4466 xoffset + (sdci[4]/10000), yoffset + (sdci[5]/10000),
4467 xoffset + (sdci[6]/10000), yoffset + (sdci[7]/10000),
4468 xoffset + (sdci[8]/10000), yoffset + (sdci[9]/10000)
4469 };
4470
4471 if(sdci[11]/10000 < 128) //translucent
4472 {
4473 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4474 }
4475
4476 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4477 {
4478 Z_scripterrlog("bitmap->Spline() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4479 return;
4480 }
4481
4482 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4483 if ( refbmp == NULL ) return;
4484
4485 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4486
4487 spline(refbmp, points, sdci[10]/10000);
4488
4489 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4490 }
4491
4492
4493 80910 void bmp_do_putpixelr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4494 {
4495 //sdci[1]=layer
4496 //sdci[2]=x
4497 //sdci[3]=y
4498 //sdci[4]=color
4499 //sdci[5]=rotation anchor x
4500 //sdci[6]=rotation anchor y
4501 //sdci[7]=rotation angle
4502 //sdci[8]=opacity
4503 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4504 80910 int32_t x1=sdci[2]/10000;
4505 80910 int32_t y1=sdci[3]/10000;
4506 80910 int32_t color=sdci[4]/10000;
4507
4508
1/2
✓ Branch 0 taken 80910 times.
✗ Branch 1 not taken.
80910 if(sdci[8]/10000<=127) //translucent
4509 {
4510 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4511 }
4512
4513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80910 times.
80910 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4514 {
4515 Z_scripterrlog("bitmap->PutPixel() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4516 return;
4517 }
4518
4519 80910 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4520
1/2
✓ Branch 0 taken 80910 times.
✗ Branch 1 not taken.
80910 if ( refbmp == NULL ) return;
4521
4522
2/4
✓ Branch 0 taken 80910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80910 times.
✗ Branch 3 not taken.
80910 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4523
4524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80910 times.
80910 if(sdci[7]!=0) //rotation
4525 {
4526 int32_t xy[2];
4527 int32_t rx=sdci[5]/10000;
4528 int32_t ry=sdci[6]/10000;
4529 fixed ra1=itofix(sdci[7]%10000)/10000;
4530 fixed ra2=itofix(sdci[7]/10000);
4531 fixed ra=ra1+ra2;
4532
4533 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4534 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4535 x1=xy[0];
4536 y1=xy[1];
4537 }
4538
4539 80910 putpixel(refbmp, x1+xoffset, y1+yoffset, color);
4540 80910 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4541 80910 }
4542
4543
4544 64994 void bmp_do_drawtiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4545 {
4546 //sdci[1]=layer
4547 //sdci[2]=x
4548 //sdci[3]=y
4549 //sdci[4]=tile
4550 //sdci[5]=tile width
4551 //sdci[6]=tile height
4552 //sdci[7]=color (cset)
4553 //sdci[8]=scale x
4554 //sdci[9]=scale y
4555 //sdci[10]=rotation anchor x
4556 //sdci[11]=rotation anchor y
4557 //sdci[12]=rotation angle
4558 //sdci[13]=flip
4559 //sdci[14]=transparency
4560 //sdci[15]=opacity
4561 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4562
4563 64994 int32_t w = sdci[5]/10000;
4564 64994 int32_t h = sdci[6]/10000;
4565
4566
4/8
✓ Branch 0 taken 64994 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64994 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64994 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 64994 times.
64994 if(w < 1 || h < 1 || h > 20 || w > 20)
4567 {
4568 return;
4569 }
4570
4571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64994 times.
64994 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4572 {
4573 Z_scripterrlog("bitmap->DrawTile() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4574 return;
4575 }
4576
4577 64994 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64994 times.
64994 if ( refbmp == NULL ) return;
4579
4580 64994 int32_t xscale=sdci[8]/10000;
4581 64994 int32_t yscale=sdci[9]/10000;
4582 64994 int32_t rx = sdci[10]/10000;
4583 64994 int32_t ry = sdci[11]/10000;
4584 64994 float rotation=sdci[12]/10000;
4585 64994 int32_t flip=(sdci[13]/10000)&3;
4586 64994 bool transparency=sdci[14]!=0;
4587 64994 int32_t opacity=sdci[15]/10000;
4588 64994 int32_t color=sdci[7]/10000;
4589
4590 64994 int32_t x1=sdci[2]/10000;
4591 64994 int32_t y1=sdci[3]/10000;
4592
1/2
✓ Branch 0 taken 64994 times.
✗ Branch 1 not taken.
64994 byte skiprows = get_qr(qr_DRAWTILE_TALL_DRAWS_WRAP_POORLY) ? 0 : h-1;
4593
4594
4595 //don't scale if it's not safe to do so
4596 64994 bool canscale = true;
4597
4598
2/4
✓ Branch 0 taken 64994 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64994 times.
64994 if(xscale==0||yscale==0)
4599 {
4600 return;
4601 }
4602
4603
3/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 64088 times.
✓ Branch 2 taken 906 times.
✗ Branch 3 not taken.
64994 if(xscale<0||yscale<0)
4604 64088 canscale = false; //default size
4605
4606
2/4
✓ Branch 0 taken 64994 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64994 times.
64994 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4607
4608
4/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 64088 times.
✓ Branch 2 taken 5644 times.
✓ Branch 3 taken 58444 times.
64994 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
4609 {
4610 6550 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16);
4611
4612
1/2
✓ Branch 0 taken 6550 times.
✗ Branch 1 not taken.
6550 if(transparency) //transparency
4613 {
4614 6550 TileHelper::OverTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip, skiprows);
4615 6550 }
4616 else //no transparency
4617 {
4618 TileHelper::OldPutTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip, skiprows);
4619 }
4620
4621
2/2
✓ Branch 0 taken 5644 times.
✓ Branch 1 taken 906 times.
6550 if(rotation != 0)
4622 {
4623 //low negative values indicate no anchor-point rotation
4624
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5644 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5644 if(rx>-777||ry>-777)
4625 {
4626 int32_t xy[2];
4627 5644 fixed ra1=itofix(sdci[12]%10000)/10000;
4628 5644 fixed ra2=itofix(sdci[12]/10000);
4629 5644 fixed ra=ra1+ra2;
4630 5644 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4631 5644 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4632 5644 x1=xy[0];
4633 5644 y1=xy[1];
4634 5644 }
4635
4636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5644 times.
5644 if(canscale) //scale first
4637 {
4638 //damnit all, .. fixme.
4639 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
4640 clear_bitmap(tempbit);
4641
4642 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
4643
4644 if(opacity < 128)
4645 {
4646 clear_bitmap(prim_bmp);
4647 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
4648 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
4649 }
4650 else
4651 {
4652 rotate_sprite(refbmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4653 }
4654
4655 destroy_bitmap(tempbit);
4656 }
4657 else //no scale
4658 {
4659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5644 times.
5644 if(opacity < 128)
4660 {
4661 clear_bitmap(prim_bmp);
4662 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
4663 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4664 }
4665 else
4666 {
4667 5644 rotate_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4668 }
4669 }
4670 5644 }
4671 else //scale only
4672 {
4673
1/2
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
906 if(canscale)
4674 {
4675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(opacity<128)
4676 {
4677 clear_bitmap(prim_bmp);
4678 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
4679 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4680 }
4681 else
4682 {
4683 906 stretch_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
4684 }
4685 906 }
4686 else //error -do not scale
4687 {
4688 if(opacity<128)
4689 {
4690 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4691 }
4692 else
4693 {
4694 draw_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset);
4695 }
4696 }
4697 }
4698
4699 6550 script_drawing_commands.ReleaseSubBitmap(pbitty);
4700
4701 6550 }
4702 else // no scale or rotation
4703 {
4704
2/2
✓ Branch 0 taken 50106 times.
✓ Branch 1 taken 8338 times.
58444 if(transparency)
4705 {
4706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50106 times.
50106 if(opacity<=127)
4707 TileHelper::OverTileTranslucent(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
4708 else
4709 50106 TileHelper::OverTile(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
4710 50106 }
4711 else
4712 {
4713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8338 times.
8338 if(opacity<=127)
4714 TileHelper::PutTileTranslucent(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
4715 else
4716 8338 TileHelper::OldPutTile(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
4717 }
4718 }
4719 64994 }
4720
4721 void bmp_do_drawtilecloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4722 {
4723 //sdci[1]=layer
4724 //sdci[2]=x
4725 //sdci[3]=y
4726 //sdci[4]=tile
4727 //sdci[5]=tile width
4728 //sdci[6]=tile height
4729 //sdci[7]=flip
4730 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4731
4732 int32_t w = sdci[5]/10000;
4733 int32_t h = sdci[6]/10000;
4734
4735 if(w < 1 || h < 1 || h > 20 || w > 20)
4736 {
4737 return;
4738 }
4739
4740 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4741 {
4742 Z_scripterrlog("bitmap->DrawTileCloaked() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4743 return;
4744 }
4745
4746 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4747 if ( refbmp == NULL ) return;
4748
4749 int32_t flip=(sdci[7]/10000)&3;
4750
4751 int32_t x1=sdci[2]/10000;
4752 int32_t y1=sdci[3]/10000;
4753 byte skiprows = get_qr(qr_DRAWTILE_TALL_DRAWS_WRAP_POORLY) ? 0 : h-1;
4754
4755 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4756
4757 TileHelper::OverTileCloaked(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, flip, skiprows);
4758 }
4759
4760
4761 11288 void bmp_do_drawcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4762 {
4763 //sdci[1]=layer
4764 //sdci[2]=x
4765 //sdci[3]=y
4766 //sdci[4]=combo
4767 //sdci[5]=tile width
4768 //sdci[6]=tile height
4769 //sdci[7]=color (cset)
4770 //sdci[8]=scale x
4771 //sdci[9]=scale y
4772 //sdci[10]=rotation anchor x
4773 //sdci[11]=rotation anchor y
4774 //sdci[12]=rotation angle
4775 //sdci[13]=frame
4776 //sdci[14]=flip
4777 //sdci[15]=transparency
4778 //sdci[16]=opacity
4779 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4780 11288 int32_t w = sdci[5]/10000;
4781 11288 int32_t h = sdci[6]/10000;
4782
4783
4/8
✓ Branch 0 taken 11288 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11288 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11288 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 11288 times.
11288 if(w<1||h<1||h>20||w>20)
4784 {
4785 return;
4786 }
4787
4788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11288 times.
11288 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4789 {
4790 Z_scripterrlog("bitmap->DrawCombo() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4791 return;
4792 }
4793
4794 11288 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4795
1/2
✓ Branch 0 taken 11288 times.
✗ Branch 1 not taken.
11288 if ( refbmp == NULL ) return;
4796 11288 int32_t cmb = (sdci[4]/10000);
4797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11288 times.
11288 if((unsigned)cmb >= MAXCOMBOS)
4798 {
4799 Z_scripterrlog("DrawCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
4800 return;
4801 }
4802
4803 11288 int32_t xscale=sdci[8]/10000;
4804 11288 int32_t yscale=sdci[9]/10000;
4805 11288 int32_t rx = sdci[10]/10000; //these work now
4806 11288 int32_t ry = sdci[11]/10000; //these work now
4807 11288 float rotation=sdci[12]/10000;
4808
4809 11288 bool transparency=sdci[15]!=0;
4810 11288 int32_t opacity=sdci[16]/10000;
4811 11288 int32_t color=sdci[7]/10000;
4812 11288 int32_t x1=sdci[2]/10000;
4813 11288 int32_t y1=sdci[3]/10000;
4814
4815 11288 auto& c = GET_DRAWING_COMBO(cmb);
4816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11288 times.
11288 if(c.animflags & AF_EDITOR_ONLY) return;
4817 11288 int frame = sdci[13] / 10000;
4818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11288 times.
11288 if (get_qr(qr_DRAWCOMBO_IGNORES_FRAME))
4819 11288 frame = -1;
4820 11288 int32_t tiletodraw = combo_tile(c, x1, y1, frame);
4821
4822 11288 int32_t flip = ((sdci[14]/10000) & 3) ^ c.flip;
4823 11288 int32_t skiprows=c.skipanimy;
4824
4825
4826 //don't scale if it's not safe to do so
4827 11288 bool canscale = true;
4828
4829
2/4
✓ Branch 0 taken 11288 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11288 times.
11288 if(xscale==0||yscale==0)
4830 {
4831 return;
4832 }
4833
4834
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11288 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11288 if(xscale<0||yscale<0)
4835 11288 canscale = false; //default size
4836
4837
2/4
✓ Branch 0 taken 11288 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11288 times.
11288 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4838
4839
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11288 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11288 times.
11288 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
4840 {
4841 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16); //-pbitty in the hisouse. :D
4842
4843 if(transparency)
4844 {
4845 TileHelper::OverTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
4846 }
4847 else //no transparency
4848 {
4849 TileHelper::OldPutTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
4850 }
4851
4852 if(rotation != 0) // rotate
4853 {
4854 //fixed point sucks ;0
4855 if(rx>-777||ry>-777) //set the rotation anchor and rotate around that
4856 {
4857 int32_t xy[2];
4858 fixed ra1=itofix(sdci[12]%10000)/10000;
4859 fixed ra2=itofix(sdci[12]/10000);
4860 fixed ra=ra1+ra2;
4861 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4862 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4863 x1=xy[0];
4864 y1=xy[1];
4865 }
4866
4867 if(canscale) //scale first
4868 {
4869 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
4870 clear_bitmap(tempbit);
4871
4872 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
4873
4874 if(opacity < 128)
4875 {
4876 clear_bitmap(prim_bmp);
4877 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
4878 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4879 }
4880 else
4881 {
4882 rotate_sprite(refbmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4883 }
4884
4885 destroy_bitmap(tempbit);
4886 }
4887 else //no scale
4888 {
4889 if(opacity < 128)
4890 {
4891 clear_bitmap(prim_bmp);
4892 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
4893 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4894 }
4895 else
4896 {
4897 rotate_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4898 }
4899 }
4900 }
4901 else //scale only
4902 {
4903 if(canscale)
4904 {
4905 if(opacity<128)
4906 {
4907 clear_bitmap(prim_bmp);
4908 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
4909 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4910 }
4911 else
4912 {
4913 stretch_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
4914 }
4915 }
4916 else //error -do not scale
4917 {
4918 if(opacity<128)
4919 {
4920 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4921 }
4922 else
4923 {
4924 draw_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset);
4925 }
4926 }
4927 }
4928
4929 script_drawing_commands.ReleaseSubBitmap(pbitty); //rap sucks
4930 }
4931 else // no scale or rotation
4932 {
4933
1/2
✓ Branch 0 taken 11288 times.
✗ Branch 1 not taken.
11288 if(transparency)
4934 {
4935
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 11006 times.
11288 if(opacity<=127)
4936 282 TileHelper::OverTileTranslucent(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
4937 else
4938 11006 TileHelper::OverTile(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
4939 11288 }
4940 else
4941 {
4942 if(opacity<=127)
4943 TileHelper::PutTileTranslucent(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
4944 else
4945 TileHelper::OldPutTile(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
4946 }
4947 }
4948 11288 }
4949
4950
4951 void bmp_do_drawcombocloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4952 {
4953 //sdci[1]=layer
4954 //sdci[2]=x
4955 //sdci[3]=y
4956 //sdci[4]=combo
4957 //sdci[5]=tile width
4958 //sdci[6]=tile height
4959 //sdci[7]=flip
4960 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4961
4962 int32_t w = sdci[5]/10000;
4963 int32_t h = sdci[6]/10000;
4964
4965 if(w<1||h<1||h>20||w>20)
4966 {
4967 return;
4968 }
4969
4970 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4971 {
4972 Z_scripterrlog("bitmap->DrawComboCloaked() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4973 return;
4974 }
4975
4976 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4977 if ( refbmp == NULL ) return;
4978 int32_t cmb = (sdci[4]/10000);
4979 if((unsigned)cmb >= MAXCOMBOS)
4980 {
4981 Z_scripterrlog("DrawComboCloaked() cannot draw combo '%d', as it is out of bounds.\n", cmb);
4982 return;
4983 }
4984
4985 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4986
4987 int32_t x1=sdci[2]/10000;
4988 int32_t y1=sdci[3]/10000;
4989
4990 auto& c = GET_DRAWING_COMBO(cmb);
4991 if(c.animflags & AF_EDITOR_ONLY) return;
4992 int32_t tiletodraw = combo_tile(c, x1, y1);
4993 int32_t flip = ((sdci[7]/10000) & 3) ^ c.flip;
4994 int32_t skiprows=c.skipanimy;
4995
4996 TileHelper::OverTileCloaked(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, flip, skiprows);
4997 }
4998
4999
5000 1982263 void bmp_do_fasttiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5001 {
5002 /* layer, x, y, tile, color opacity */
5003 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5004
5005 1982263 int32_t opacity = sdci[6]/10000;
5006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1982263 times.
1982263 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5007 {
5008 Z_scripterrlog("bitmap->FastTile() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5009 return;
5010 }
5011 1982263 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5012
1/2
✓ Branch 0 taken 1982263 times.
✗ Branch 1 not taken.
1982263 if ( refbmp == NULL ) return;
5013
5014
2/4
✓ Branch 0 taken 1982263 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1982263 times.
✗ Branch 3 not taken.
1982263 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5015
5016 1982263 int x = xoffset+(sdci[2]/10000);
5017 1982263 int y = yoffset+(sdci[3]/10000);
5018
5019
2/2
✓ Branch 0 taken 29119 times.
✓ Branch 1 taken 1953144 times.
1982263 if(opacity < 128)
5020 29119 overtiletranslucent16(refbmp, sdci[4]/10000, x, y, sdci[5]/10000, 0, opacity);
5021 else
5022 1953144 overtile16(refbmp, sdci[4]/10000, x, y, sdci[5]/10000, 0);
5023 1982263 }
5024
5025 19821648 void do_bmpwritetile(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5026 {
5027 /* layer, x, y, tile, is8bit, mask */
5028 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19821648 times.
19821648 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5030 {
5031 Z_scripterrlog("bitmap->WriteTile() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5032 return;
5033 }
5034 19821648 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5035
1/2
✓ Branch 0 taken 19821648 times.
✗ Branch 1 not taken.
19821648 if ( refbmp == NULL ) return;
5036
5037
2/4
✓ Branch 0 taken 19821648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19821648 times.
✗ Branch 3 not taken.
19821648 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5038
5039 19821648 int32_t x = (sdci[2]/10000), y = (sdci[3]/10000), tl = (sdci[4]/10000);
5040 19821648 bool is8bit = sdci[5]!=0, mask = sdci[6]!=0;
5041
5042 19821648 write_tile(newtilebuf, refbmp, tl, x+xoffset, y+yoffset, is8bit, mask);
5043 19821648 }
5044
5045 void do_bmpdither(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5046 {
5047 /* layer, mask, color, ditherType, ditherArg */
5048 //sdci[2] Mask Bitmap Pointer
5049 //sdci[3] Color
5050 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5051 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5052 {
5053 Z_scripterrlog("bitmap->Dither() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5054 return;
5055 }
5056 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5057 if ( refbmp == NULL ) return;
5058 if ( sdci[2] <= 0 )
5059 {
5060 Z_scripterrlog("bitmap->Dither() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[2]);
5061 return;
5062 }
5063 BITMAP *mask = resolveScriptingBitmap(sdci[2]);
5064 if ( mask == NULL ) return;
5065
5066 int32_t dType = sdci[4] / 10000L;
5067 if(dType < 0 || dType >= dithMax)
5068 {
5069 Z_scripterrlog("bitmap->Dither() used an invalid dither type: %d. Aborting.\n", dType);
5070 return;
5071 }
5072
5073 ditherblit(refbmp, mask, byte(sdci[3]/10000L), dType, sdci[5]/10000L);
5074 }
5075
5076 7323 void do_bmpreplcol(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5077 {
5078 /* layer, shift, startcol, endcol */
5079 //sdci[2] NewCol
5080 //sdci[3] StartCol
5081 //sdci[4] EndCol
5082 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7323 times.
7323 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5084 {
5085 Z_scripterrlog("bitmap->ReplaceColors() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5086 return;
5087 }
5088 7323 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7323 times.
7323 if ( refbmp == NULL ) return;
5090 7323 replColor(refbmp, sdci[2]/10000L, sdci[3]/10000L, sdci[4]/10000L, false);
5091 7323 }
5092
5093 void do_bmpshiftcol(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5094 {
5095 /* layer, shift, startcol, endcol */
5096 //sdci[2] ShiftAmount
5097 //sdci[3] StartCol
5098 //sdci[4] EndCol
5099 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5100 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5101 {
5102 Z_scripterrlog("bitmap->ShiftColors() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5103 return;
5104 }
5105 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5106 if ( refbmp == NULL ) return;
5107 replColor(refbmp, sdci[2]/10000L, sdci[3]/10000L, sdci[4]/10000L, true);
5108 }
5109
5110 906 void do_bmpmaskdraw(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5111 {
5112 /* layer, mask, color */
5113 //sdci[2] Mask Bitmap Pointer
5114 //sdci[3] Color
5115 //sdci[4] start mask color
5116 //sdci[5] end mask color
5117 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5118 906 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5119
1/2
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
906 if ( refbmp == NULL )
5120 {
5121 Z_scripterrlog("bitmap->MaskDraw() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5122 return;
5123 }
5124 906 BITMAP *mask = resolveScriptingBitmap(sdci[2]);
5125
1/2
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
906 if ( mask == NULL )
5126 {
5127 Z_scripterrlog("bitmap->MaskDraw() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[2]);
5128 return;
5129 }
5130 906 auto fillcol = sdci[3]/10000L;
5131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(unsigned(fillcol) > 0xFF) return; //invalid color, nothing to draw
5132 906 auto startcol = vbound(sdci[4]/10000L,0x00,0xFF);
5133 906 auto endcol = vbound(sdci[5]/10000L,0x00,0xFF);
5134 906 mask_colorfill(refbmp, mask, fillcol, startcol, endcol);
5135 906 }
5136
5137 void do_bmpmaskblit(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5138 {
5139 /* layer, mask, color */
5140 //sdci[2] Mask Bitmap Pointer
5141 //sdci[3] Pattern Bitmap
5142 //sdci[4] bool 'pattern repeats'
5143 //sdci[5] start mask color
5144 //sdci[6] end mask color
5145 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5146 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5147 if ( refbmp == NULL )
5148 {
5149 Z_scripterrlog("bitmap->MaskDraw() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5150 return;
5151 }
5152 BITMAP *mask = resolveScriptingBitmap(sdci[2]);
5153 if ( mask == NULL )
5154 {
5155 Z_scripterrlog("bitmap->MaskDraw() wanted to read from an invalid bitmap (mask) id: %d. Aborting.\n", sdci[2]);
5156 return;
5157 }
5158 BITMAP *pattern = resolveScriptingBitmap(sdci[3]);
5159 if ( pattern == NULL )
5160 {
5161 Z_scripterrlog("bitmap->MaskDraw() wanted to read from an invalid bitmap (pattern) id: %d. Aborting.\n", sdci[3]);
5162 return;
5163 }
5164 bool repeats = sdci[4]!=0;
5165 auto startcol = vbound(sdci[5]/10000L,0x00,0xFF);
5166 auto endcol = vbound(sdci[6]/10000L,0x00,0xFF);
5167 mask_blit(refbmp, mask, pattern, repeats, startcol, endcol);
5168 }
5169
5170 40175665 void bmp_do_fastcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5171 {
5172 /* layer, x, y, tile, color opacity */
5173 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5174 40175665 int32_t opacity = sdci[6] / 10000;
5175 40175665 int32_t x1 = sdci[2] / 10000;
5176 40175665 int32_t y1 = sdci[3] / 10000;
5177 40175665 int32_t index = sdci[4]/10000;
5178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40175665 times.
40175665 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5179 {
5180 Z_scripterrlog("bitmap->FastCombo() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5181 return;
5182 }
5183 40175665 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5184
1/2
✓ Branch 0 taken 40175665 times.
✗ Branch 1 not taken.
40175665 if ( refbmp == NULL ) return;
5185 40175665 int32_t cmb = (sdci[4]/10000);
5186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40175665 times.
40175665 if((unsigned)cmb >= MAXCOMBOS)
5187 {
5188 Z_scripterrlog("FastCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
5189 return;
5190 }
5191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40175665 times.
40175665 if(combobuf[cmb].animflags & AF_EDITOR_ONLY) return;
5192
5193
2/4
✓ Branch 0 taken 40175665 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40175665 times.
✗ Branch 3 not taken.
40175665 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5194
5195 40175665 int x = xoffset+x1;
5196 40175665 int y = yoffset+y1;
5197
5198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40175665 times.
40175665 if(opacity < 128)
5199 {
5200 overcomboblocktranslucent(refbmp, x, y, cmb, sdci[5]/10000, 1, 1, 128);
5201
5202 }
5203 else
5204 {
5205 40175665 overcomboblock(refbmp, x, y, cmb, sdci[5]/10000, 1, 1);
5206 }
5207 40175665 }
5208
5209
5210
5211 void bmp_do_drawcharr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5212 {
5213 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5214 {
5215 Z_scripterrlog("bitmap->DrawCharacter() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5216 return;
5217 }
5218 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5219 if ( refbmp == NULL ) return;
5220
5221 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5222
5223 //broken 2.50.2 and earlier drawcharacter()
5224 if ( get_qr(qr_BROKENCHARINTDRAWING) )
5225 {
5226 //sdci[1]=layer
5227 //sdci[2]=x
5228 //sdci[3]=y
5229 //sdci[4]=font
5230 //sdci[5]=color
5231 //sdci[6]=bg color
5232 //sdci[7]=strech x (width)
5233 //sdci[8]=stretch y (height)
5234 //sdci[9]=char
5235 //sdci[10]=opacity
5236 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5237
5238 int32_t x=sdci[2]/10000;
5239 int32_t y=sdci[3]/10000;
5240 int32_t font_index=sdci[4]/10000;
5241 int32_t color=sdci[5]/10000;
5242 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5243 int32_t w=sdci[7]/10000;
5244 int32_t h=sdci[8]/10000;
5245 char glyph=char(sdci[9]/10000);
5246 int32_t opacity=sdci[10]/10000;
5247
5248 //safe check
5249 if(bg_color < -1) bg_color = -1;
5250
5251 if(w>512) w=512; //w=vbound(w,0,512);
5252
5253 if(h>512) h=512; //h=vbound(h,0,512);
5254
5255 //undone
5256 if(w>0&&h>0)//stretch the character
5257 {
5258 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
5259
5260 if(opacity < 128)
5261 {
5262 if(w>128||h>128)
5263 {
5264 clear_bitmap(prim_bmp);
5265
5266 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5267 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5268 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5269 }
5270 else //this is faster
5271 {
5272 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
5273
5274 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5275 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5276 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5277
5278 script_drawing_commands.ReleaseSubBitmap(pbmp2);
5279 }
5280 }
5281 else // no opacity
5282 {
5283 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5284 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5285 }
5286
5287 }
5288 else //no stretch
5289 {
5290 if(opacity < 128)
5291 {
5292 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
5293 clear_bitmap(pbmp);
5294
5295 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5296 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5297
5298 destroy_bitmap(pbmp);
5299 }
5300 else // no opacity
5301 {
5302 textprintf_ex(refbmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
5303 }
5304 }
5305 }
5306
5307 else //2.53.0 fixed version and later.
5308 {
5309
5310 //sdci[1]=layer
5311 //sdci[2]=x
5312 //sdci[3]=y
5313 //sdci[4]=font
5314 //sdci[5]=color
5315 //sdci[6]=bg color
5316 //sdci[7]=strech x (width)
5317 //sdci[8]=stretch y (height)
5318 //sdci[9]=char
5319 //sdci[10]=opacity
5320
5321 int32_t x=sdci[2]/10000;
5322 int32_t y=sdci[3]/10000;
5323 int32_t font_index=sdci[4]/10000;
5324 int32_t color=sdci[5]/10000;
5325 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5326 int32_t w=sdci[7]/10000;
5327 int32_t h=sdci[8]/10000;
5328 char glyph=char(sdci[9]/10000);
5329 int32_t opacity=sdci[10]/10000;
5330
5331 //safe check
5332 if(bg_color < -1) bg_color = -1;
5333
5334 if(w>512) w=512; //w=vbound(w,0,512);
5335
5336 if(h>512) h=512; //h=vbound(h,0,512);
5337
5338 //undone
5339 if(w>0&&h>0)//stretch the character
5340 {
5341 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
5342
5343 if(opacity < 128)
5344 {
5345 if(w>128||h>128)
5346 {
5347 clear_bitmap(prim_bmp);
5348
5349 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5350 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5351 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5352 }
5353 else //this is faster
5354 {
5355 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
5356
5357 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5358 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5359 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5360
5361 script_drawing_commands.ReleaseSubBitmap(pbmp2);
5362 }
5363 }
5364 else // no opacity
5365 {
5366 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5367 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5368 }
5369
5370 }
5371 else //no stretch
5372 {
5373 if(opacity < 128)
5374 {
5375 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
5376 clear_bitmap(pbmp);
5377
5378 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5379 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5380
5381 destroy_bitmap(pbmp);
5382 }
5383 else // no opacity
5384 {
5385 textprintf_ex(refbmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
5386 }
5387 }
5388
5389 }
5390
5391 }
5392
5393
5394 void bmp_do_drawintr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5395 {
5396 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5397 {
5398 Z_scripterrlog("bitmap->DrawInteger() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5399 return;
5400 }
5401 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5402 if ( refbmp == NULL ) return;
5403
5404 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5405
5406 //broken 2.50.2 and earlier drawinteger()
5407 if ( get_qr(qr_BROKENCHARINTDRAWING) )
5408 {
5409 //sdci[1]=layer
5410 //sdci[2]=x
5411 //sdci[3]=y
5412 //sdci[4]=font
5413 //sdci[5]=color
5414 //sdci[6]=bg color
5415 //sdci[7]=strech x (width)
5416 //sdci[8]=stretch y (height)
5417 //sdci[9]=integer
5418 //sdci[10]=num decimal places
5419 //sdci[11]=opacity
5420 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5421
5422 int32_t x=sdci[2]/10000;
5423 int32_t y=sdci[3]/10000;
5424 int32_t font_index=sdci[4]/10000;
5425 int32_t color=sdci[5]/10000;
5426 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5427 int32_t w=sdci[7]/10000;
5428 int32_t h=sdci[8]/10000;
5429 int32_t decplace=sdci[10]/10000;
5430 int32_t opacity=sdci[11]/10000;
5431
5432 //safe check
5433 if(bg_color < -1) bg_color = -1;
5434
5435 if(w>512) w=512; //w=vbound(w,0,512);
5436
5437 if(h>512) h=512; //h=vbound(h,0,512);
5438
5439 char numbuf[15];
5440
5441 switch(decplace)
5442 {
5443 default:
5444 case 0:
5445 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
5446 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
5447
5448 case 1:
5449 //sprintf(numbuf,"%.01f",number);
5450 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
5451 break;
5452
5453 case 2:
5454 //sprintf(numbuf,"%.02f",number);
5455 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
5456 break;
5457
5458 case 3:
5459 //sprintf(numbuf,"%.03f",number);
5460 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
5461 break;
5462
5463 case 4:
5464 //sprintf(numbuf,"%.04f",number);
5465 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
5466 break;
5467 }
5468
5469 if(w>0&&h>0)//stretch
5470 {
5471 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
5472
5473 if(opacity < 128)
5474 {
5475 if(w>128||h>128)
5476 {
5477 clear_bitmap(prim_bmp);
5478
5479 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5480 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5481 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5482 }
5483 else
5484 {
5485 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
5486 clear_bitmap(pbmp2);
5487
5488 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5489 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5490 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5491
5492 destroy_bitmap(pbmp2);
5493 }
5494 }
5495 else // no opacity
5496 {
5497 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5498 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5499 }
5500
5501 }
5502 else //no stretch
5503 {
5504 if(opacity < 128)
5505 {
5506 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
5507 clear_bitmap(pbmp);
5508
5509 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5510 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5511
5512 destroy_bitmap(pbmp);
5513 }
5514 else // no opacity
5515 {
5516 textout_ex(refbmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
5517 }
5518 }
5519
5520 }
5521
5522 else //2.53.0 fixed version and later.
5523 {
5524 //sdci[1]=layer
5525 //sdci[2]=x
5526 //sdci[3]=y
5527 //sdci[4]=font
5528 //sdci[5]=color
5529 //sdci[6]=bg color
5530 //sdci[7]=strech x (width)
5531 //sdci[8]=stretch y (height)
5532 //sdci[9]=integer
5533 //sdci[10]=num decimal places
5534 //sdci[11]=opacity
5535
5536 int32_t x=sdci[2]/10000;
5537 int32_t y=sdci[3]/10000;
5538 int32_t font_index=sdci[4]/10000;
5539 int32_t color=sdci[5]/10000;
5540 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5541 int32_t w=sdci[7]/10000;
5542 int32_t h=sdci[8]/10000;
5543 int32_t decplace=sdci[10]/10000;
5544 int32_t opacity=sdci[11]/10000;
5545
5546 //safe check
5547 if(bg_color < -1) bg_color = -1;
5548
5549 if(w>512) w=512; //w=vbound(w,0,512);
5550
5551 if(h>512) h=512; //h=vbound(h,0,512);
5552
5553 char numbuf[15];
5554
5555 switch(decplace)
5556 {
5557 default:
5558 case 0:
5559 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
5560 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
5561
5562 case 1:
5563 //sprintf(numbuf,"%.01f",number);
5564 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
5565 break;
5566
5567 case 2:
5568 //sprintf(numbuf,"%.02f",number);
5569 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
5570 break;
5571
5572 case 3:
5573 //sprintf(numbuf,"%.03f",number);
5574 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
5575 break;
5576
5577 case 4:
5578 //sprintf(numbuf,"%.04f",number);
5579 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
5580 break;
5581 }
5582
5583 //FONT* font=get_zc_font(sdci[4]/10000);
5584
5585 if(w>0&&h>0)//stretch
5586 {
5587 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(get_zc_font(font_index), numbuf)+1, text_height(get_zc_font(font_index)));
5588 clear_bitmap(pbmp);
5589 //script_drawing_commands.GetSmallTextureBitmap(1,1);
5590
5591 if(opacity < 128)
5592 {
5593 if(w>128||h>128)
5594 {
5595 clear_bitmap(prim_bmp);
5596
5597 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5598 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5599 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5600 }
5601 else
5602 {
5603 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
5604 clear_bitmap(pbmp2);
5605
5606 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5607 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5608 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5609
5610 destroy_bitmap(pbmp2);
5611 }
5612 }
5613 else // no opacity
5614 {
5615 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5616 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5617 }
5618
5619 }
5620 else //no stretch
5621 {
5622 if(opacity < 128)
5623 {
5624 FONT* font = get_zc_font(font_index);
5625 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(font, numbuf), text_height(font));
5626 clear_bitmap(pbmp);
5627
5628 textout_ex(pbmp, font, numbuf, 0, 0, color, bg_color);
5629 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5630
5631 destroy_bitmap(pbmp);
5632 }
5633 else // no opacity
5634 {
5635 textout_ex(refbmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
5636 }
5637 }
5638 }
5639 }
5640
5641
5642 865 void bmp_do_drawstringr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5643 {
5644 //sdci[1]=layer
5645 //sdci[2]=x
5646 //sdci[3]=y
5647 //sdci[4]=font
5648 //sdci[5]=color
5649 //sdci[6]=bg color
5650 //sdci[7]=format_option
5651 //sdci[8]=string
5652 //sdci[9]=opacity
5653 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5655 {
5656 Z_scripterrlog("bitmap->DrawString() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5657 return;
5658 }
5659
5660 865 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5661
1/2
✓ Branch 0 taken 865 times.
✗ Branch 1 not taken.
865 if ( refbmp == NULL ) return;
5662
5663
2/4
✓ Branch 0 taken 865 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 865 times.
865 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5664
5665 865 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5666
5667
1/2
✓ Branch 0 taken 865 times.
✗ Branch 1 not taken.
865 if(!str)
5668 {
5669 al_trace("String pointer is null! Internal error. \n");
5670 return;
5671 }
5672
5673 865 int32_t x=sdci[2]/10000;
5674 865 int32_t y=sdci[3]/10000;
5675 865 FONT* font=get_zc_font(sdci[4]/10000);
5676 865 int32_t color=sdci[5]/10000;
5677 865 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5678 865 int32_t format_type=sdci[7]/10000;
5679 865 int32_t opacity=sdci[9]/10000;
5680 //sdci[8] not needed :)
5681
5682 //safe check
5683
1/2
✓ Branch 0 taken 865 times.
✗ Branch 1 not taken.
865 if(bg_color < -1) bg_color = -1;
5684
5685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 if(opacity < 128)
5686 {
5687 int32_t width=zc_min(text_length(font, str->c_str()), 512);
5688 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
5689 clear_bitmap(pbmp);
5690 textout_ex(pbmp, font, str->c_str(), 0, 0, color, bg_color);
5691 if(format_type == 2) // right-sided text
5692 x-=width;
5693 else if(format_type == 1) // centered text
5694 x-=width/2;
5695 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5696 destroy_bitmap(pbmp);
5697 }
5698 else // no opacity
5699 {
5700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 if(format_type == 2) // right-sided text
5701 {
5702 textout_right_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
5703 }
5704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 else if(format_type == 1) // centered text
5705 {
5706 textout_centre_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
5707 }
5708 else // standard left-sided text
5709 {
5710 865 textout_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
5711 }
5712 }
5713 865 }
5714
5715 45504 void bmp_do_drawstringr2(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5716 {
5717 //sdci[1]=layer
5718 //sdci[2]=x
5719 //sdci[3]=y
5720 //sdci[4]=font
5721 //sdci[5]=color
5722 //sdci[6]=bg color
5723 //sdci[7]=format_option
5724 //sdci[8]=string
5725 //sdci[9]=opacity
5726 //sdci[10]=shadowtype
5727 //sdci[11]=shadow_color
5728 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45504 times.
45504 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5730 {
5731 Z_scripterrlog("bitmap->DrawString() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5732 return;
5733 }
5734
5735 45504 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5736
1/2
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
45504 if ( refbmp == NULL ) return;
5737
5738
2/4
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 45504 times.
45504 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5739
5740 45504 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5741
5742
1/2
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
45504 if(!str)
5743 {
5744 al_trace("String pointer is null! Internal error. \n");
5745 return;
5746 }
5747
5748 45504 int32_t x=sdci[2]/10000;
5749 45504 int32_t y=sdci[3]/10000;
5750 45504 FONT* font=get_zc_font(sdci[4]/10000);
5751 45504 int32_t color=sdci[5]/10000;
5752 45504 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5753 45504 int32_t format_type=sdci[7]/10000;
5754 45504 int32_t opacity=sdci[9]/10000;
5755 45504 int32_t textstyle = sdci[10]/10000;
5756 45504 int32_t shadow_color = sdci[11]/10000;
5757 //sdci[8] not needed :)
5758
5759 //safe check
5760
1/2
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
45504 if(bg_color < -1) bg_color = -1;
5761
5762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45504 times.
45504 if(opacity < 128)
5763 {
5764 int32_t width=zc_min(text_length(font, str->c_str()), 512);
5765 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
5766 clear_bitmap(pbmp);
5767 textout_styled_aligned_ex(pbmp, font, str->c_str(), 0, 0, textstyle, ALIGN_LEFT, color, shadow_color, bg_color);
5768 if(format_type == 2) // right-sided text
5769 x-=width;
5770 else if(format_type == 1) // centered text
5771 x-=width/2;
5772 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5773 destroy_bitmap(pbmp);
5774 }
5775 else // no opacity
5776 {
5777 45504 textout_styled_aligned_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, textstyle, format_type, color, shadow_color, bg_color);
5778 }
5779 45504 }
5780
5781 2134433 void bmp_do_clearr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5782 {
5783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2134433 times.
2134433 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5784 {
5785 Z_scripterrlog("bitmap->Clear() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5786 return;
5787 }
5788
5789 2134433 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2134433 times.
2134433 if ( !refbmp ) return;
5791
5792 2134433 clear_bitmap(refbmp);
5793 2134433 }
5794
5795 34749 void bmp_do_clearcolorr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5796 {
5797 //sdci[1]=layer
5798 //sdci[2]=color
5799 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5800 34749 int32_t pal_color = sdci[2]/10000;
5801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34749 times.
34749 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5802 {
5803 Z_scripterrlog("bitmap->ClearToColor() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5804 return;
5805 }
5806
5807 34749 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34749 times.
34749 if ( !refbmp ) return;
5809
5810 34749 clear_to_color(refbmp, pal_color);
5811 34749 }
5812
5813
5814 43007 void bmp_do_regenr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5815 {
5816 //sdci[1]=layer
5817 43007 int32_t h = sdci[3]/10000;
5818 43007 int32_t w = sdci[2]/10000;
5819
1/2
✓ Branch 0 taken 43007 times.
✗ Branch 1 not taken.
43007 if ( get_qr(qr_OLDCREATEBITMAP_ARGS) )
5820 {
5821 //flip height and width
5822 h = h ^ w;
5823 w = h ^ w;
5824 h = h ^ w;
5825 }
5826 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5827 //Z_scripterrlog("bitmap->Create() pointer is: %d\n", sdci[DRAWCMD_BMP_TARGET]);
5828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43007 times.
43007 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5829 {
5830 Z_scripterrlog("bitmap->Create() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5831 return;
5832 }
5833 43007 int32_t bitid = sdci[DRAWCMD_BMP_TARGET];
5834 43007 auto& usr_bmp = scb.get(bitid);
5835
2/2
✓ Branch 0 taken 42757 times.
✓ Branch 1 taken 250 times.
43007 if ( usr_bmp.u_bmp )
5836 42757 destroy_bitmap(usr_bmp.u_bmp);
5837 43007 usr_bmp.u_bmp = create_bitmap_ex(8,w,h);
5838
5839 43007 usr_bmp.width = w;
5840 43007 usr_bmp.height = h;
5841 43007 }
5842
5843 void bmp_do_readr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5844 {
5845 //sdci[1]=layer
5846 //sdci[2]=filename
5847 //sdci[3]=y
5848 //sdci[4]=font
5849 //sdci[5]=color
5850 //sdci[6]=bg color
5851 //sdci[7]=format_option
5852 //sdci[8]=string
5853 //sdci[9]=opacity
5854 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5855 //Z_scripterrlog("bitmap->Read() pointer is: %d\n", sdci[DRAWCMD_BMP_TARGET]);
5856 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5857 {
5858 Z_scripterrlog("bitmap->Read() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5859 return;
5860 }
5861 int32_t bitid = sdci[DRAWCMD_BMP_TARGET];
5862 auto& usr_bitmap = scb.get(bitid);
5863 usr_bitmap.destroy();
5864
5865 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5866
5867 if(!str)
5868 {
5869 al_trace("String pointer is null! Internal error. \n");
5870 return;
5871 }
5872
5873 PALETTE tempPal;
5874 get_palette(tempPal);
5875 if ( checkPath(str->c_str(), false) )
5876 {
5877 usr_bitmap.u_bmp = load_bitmap(str->c_str(), tempPal);
5878 usr_bitmap.width = usr_bitmap.u_bmp->w;
5879 usr_bitmap.height = usr_bitmap.u_bmp->h;
5880 if ( !usr_bitmap.u_bmp )
5881 {
5882 Z_scripterrlog("Failed to load image file %s.\nMaking a blank bitmap on the pointer.\n", str->c_str());
5883 }
5884 else
5885 {
5886 zprint("Read image file %s\n",str->c_str());
5887 }
5888 }
5889 else
5890 {
5891 Z_scripterrlog("Failed to load image file: %s. File not found. Creating a blank bitmap on the pointer.\n", str->c_str());
5892 usr_bitmap.u_bmp = create_bitmap_ex(8,256,176);
5893 clear_bitmap(usr_bitmap.u_bmp);
5894 }
5895 }
5896
5897
5898
5899 void bmp_do_writer(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5900 {
5901 //sdci[1]=layer
5902 //sdci[2]=filename
5903 //sdci[3]=y
5904 //sdci[4]=font
5905 //sdci[5]=color
5906 //sdci[6]=bg color
5907 //sdci[7]=format_option
5908 //sdci[8]=string
5909 //sdci[9]=opacity
5910 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5911 //Z_scripterrlog("bitmap->Write() pointer is: %d\n", sdci[DRAWCMD_BMP_TARGET]);
5912
5913 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5914 {
5915 Z_scripterrlog("bitmap->Write() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5916 return;
5917 }
5918
5919 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5920 if ( !refbmp ) return;
5921
5922 bool overwrite = (sdci[3] != 0);
5923 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5924
5925 if(!str)
5926 {
5927 al_trace("String pointer is null! Internal error. \n");
5928 return;
5929 }
5930
5931 //char *cptr = new char[str->size()+1]; // +1 to account for \0 byte
5932 //std::strncpy(cptr, str->c_str(), str->size());
5933 //Z_scripterrlog("bitmap->Write extension matches ? : %s\n!", (FFCore.checkExtension(str->c_str(), ".png")) ? "true" : "false");
5934 //Z_scripterrlog("Trying to write filename %s\n", cptr);
5935 if
5936 (
5937 ( (FFCore.checkExtension(*str, "")) ) ||
5938 ( !(FFCore.checkExtension(*str, ".png")) && !(FFCore.checkExtension(*str, ".gif")) && !(FFCore.checkExtension(*str, ".bmp"))
5939 && !(FFCore.checkExtension(*str, ".pcx")) && !(FFCore.checkExtension(*str, ".tga")) )
5940 )
5941 {
5942 Z_scripterrlog("No extension, or invalid extension provided for writing bitmap file %s. Could not write the file.\nValid types are .png, .gif, .pcx, .tgx, and .bmp. Aborting.\n",str->c_str());
5943 }
5944 else if ( overwrite || (!checkPath(str->c_str(), false)) )
5945 {
5946 if(make_dirs_for_file(*str))
5947 {
5948 save_bitmap(str->c_str(), refbmp, RAMpal);
5949 if(checkPath(str->c_str(), false))
5950 {
5951 zprint("Wrote image file %s\n",str->c_str());
5952 }
5953 else
5954 {
5955 Z_scripterrlog("Failed to create file '%s'\n",str->c_str());
5956 }
5957 }
5958 else
5959 {
5960 Z_scripterrlog("Cannot write file '%s' because the directory does not exist, and could not be created.\n", str->c_str());
5961 }
5962 }
5963 else Z_scripterrlog("Cannot write file '%s' because the file already exists in the specified path.\n", str->c_str());
5964 }
5965
5966
5967 void bmp_do_drawquadr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5968 {
5969 //sdci[1]=layer
5970 //sdci[2]=x1
5971 //sdci[3]=y1
5972 //sdci[4]=x2
5973 //sdci[5]=y2
5974 //sdci[6]=x3
5975 //sdci[7]=y3
5976 //sdci[8]=x4
5977 //sdci[9]=y4
5978 //sdci[10]=width
5979 //sdci[11]=height
5980 //sdci[12]=cset
5981 //sdci[13]=flip
5982 //sdci[14]=tile/combo
5983 //sdci[15]=polytype
5984 //sdci[16] = other bitmap as texture
5985 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5986 Z_scripterrlog("bitmap quad pointer: %d\n", sdci[DRAWCMD_BMP_TARGET]);
5987 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5988 {
5989 Z_scripterrlog("bitmap->Quad() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5990 return;
5991 }
5992 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5993
5994 if ( !refbmp ) return;
5995
5996 int32_t x1 = sdci[2]/10000;
5997 int32_t y1 = sdci[3]/10000;
5998 int32_t x2 = sdci[4]/10000;
5999 int32_t y2 = sdci[5]/10000;
6000 int32_t x3 = sdci[6]/10000;
6001 int32_t y3 = sdci[7]/10000;
6002 int32_t x4 = sdci[8]/10000;
6003 int32_t y4 = sdci[9]/10000;
6004 int32_t w = sdci[10]/10000;
6005 int32_t h = sdci[11]/10000;
6006 int32_t color = sdci[12]/10000;
6007 int32_t flip=(sdci[13]/10000)&3;
6008 int32_t tile = sdci[14]/10000;
6009 int32_t polytype = sdci[15]/10000;
6010 int32_t quad_render_source = sdci[16];
6011 //Z_scripterrlog("bitmap->Quad() render source is: %d\n", quad_render_source);
6012
6013 bool tex_is_bitmap = ( sdci[16] != 0 );
6014
6015 BITMAP *bmptexture=NULL;
6016 BITMAP *tex=NULL;
6017 polytype = vbound(polytype, 0, 14);
6018
6019 int32_t col[4];
6020 col[0]=col[1]=col[2]=col[3]=color;
6021 bool mustDestroyBmp = false;
6022
6023 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
6024
6025 if ( tex_is_bitmap )
6026 {
6027 bmptexture = resolveScriptingBitmap(quad_render_source);
6028 if ( !bmptexture )
6029 {
6030 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Triangle3()");
6031 tex_is_bitmap = 0;
6032 }
6033 }
6034
6035 if ( tex_is_bitmap )
6036 {
6037
6038 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
6039 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
6040 if ( !isPowerOfTwo(w) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", w);
6041 if ( !isPowerOfTwo(h) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", h);
6042
6043 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6044 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(h), col[1] };
6045 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(w), static_cast<float>(h), col[2] };
6046 V3D_f V4 = { static_cast<float>(x4+xoffset), static_cast<float>(y4+yoffset), 0, static_cast<float>(w), 0, col[3] };
6047
6048 quad3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3, &V4);
6049 }
6050 else
6051 {
6052 tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
6053 if(!tex)
6054 {
6055 //Z_scripterrlog("Bitmap->Quad() found an invalid texture bitmap.\n");
6056 mustDestroyBmp = true;
6057 tex = create_bitmap_ex(8, w*16, h*16);
6058 clear_bitmap(tex);
6059 }
6060
6061 if(tile > 0) // TILE
6062 {
6063 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
6064 }
6065
6066 if ( tile < 0 ) // COMBO
6067 {
6068 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
6069 const int32_t tiletodraw = combo_tile(c, x1, y1);
6070 flip = flip ^ c.flip;
6071
6072 if(!(c.animflags & AF_EDITOR_ONLY))
6073 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
6074 }
6075 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
6076 {
6077 Z_message("Quad() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
6078 return; //non power of two error
6079 }
6080 //Z_scripterrlog("bitmap->Quad() is trying to blit from a bitmap texture.\n");
6081 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6082 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(h), col[1] };
6083 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(w), static_cast<float>(h), col[2] };
6084 V3D_f V4 = { static_cast<float>(x4+xoffset), static_cast<float>(y4+yoffset), 0, static_cast<float>(w), 0, col[3] };
6085
6086 quad3d_f(refbmp, polytype, tex, &V1, &V2, &V3, &V4);
6087
6088 }
6089
6090
6091
6092
6093 //todo: finish palette shading
6094 /*
6095 POLYTYPE_FLAT
6096 POLYTYPE_GCOL
6097 POLYTYPE_GRGB
6098 POLYTYPE_ATEX
6099 POLYTYPE_PTEX
6100 POLYTYPE_ATEX_MASK
6101 POLYTYPE_PTEX_MASK
6102 POLYTYPE_ATEX_LIT
6103 POLYTYPE_PTEX_LIT
6104 POLYTYPE_ATEX_MASK_LIT
6105 POLYTYPE_PTEX_MASK_LIT
6106 POLYTYPE_ATEX_TRANS
6107 POLYTYPE_PTEX_TRANS
6108 POLYTYPE_ATEX_MASK_TRANS
6109 POLYTYPE_PTEX_MASK_TRANS
6110 */
6111
6112 if(mustDestroyBmp)
6113 destroy_bitmap(tex);
6114
6115 }
6116
6117 void bmp_do_drawtriangler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
6118 {
6119 //sdci[1]=layer
6120 //sdci[2]=x1
6121 //sdci[3]=y1
6122 //sdci[4]=x2
6123 //sdci[5]=y2
6124 //sdci[6]=x3
6125 //sdci[7]=y3
6126 //sdci[8]=width
6127 //sdci[9]=height
6128 //sdci[10]=cset
6129 //sdci[11]=flip
6130 //sdci[12]=tile/combo
6131 //sdci[13]=polytype
6132 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
6133 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
6134 {
6135 Z_scripterrlog("bitmap->Triangle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
6136 return;
6137 }
6138 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
6139 if ( refbmp == NULL ) return;
6140
6141
6142 int32_t render_source = sdci[14];
6143 //Z_scripterrlog("bitmap->Triangle() render source is: %d\n", render_source);
6144
6145 bool tex_is_bitmap = ( sdci[14] != 0 );
6146
6147 BITMAP *bmptexture=NULL;
6148 if ( tex_is_bitmap )
6149 {
6150 bmptexture = resolveScriptingBitmap(render_source);
6151 if ( !bmptexture )
6152 {
6153 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Triangle3()");
6154 tex_is_bitmap = 0;
6155 }
6156 }
6157
6158 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
6159
6160 int32_t x1 = sdci[2]/10000;
6161 int32_t y1 = sdci[3]/10000;
6162 int32_t x2 = sdci[4]/10000;
6163 int32_t y2 = sdci[5]/10000;
6164 int32_t x3 = sdci[6]/10000;
6165 int32_t y3 = sdci[7]/10000;
6166 int32_t w = sdci[8]/10000;
6167 int32_t h = sdci[9]/10000;
6168 int32_t color = sdci[10]/10000;
6169 int32_t flip=(sdci[11]/10000)&3;
6170 int32_t tile = sdci[12]/10000;
6171 int32_t polytype = sdci[13]/10000;
6172
6173 polytype = vbound(polytype, 0, 14);
6174 int32_t utex_w = w;
6175 int32_t utex_h = h;
6176
6177
6178 int32_t tex_width = w*16;
6179 int32_t tex_height = h*16;
6180
6181 bool mustDestroyBmp = false;
6182 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
6183
6184 if(!tex)
6185 {
6186 mustDestroyBmp = true;
6187 tex = create_bitmap_ex(8, tex_width, tex_height);
6188 clear_bitmap(tex);
6189 }
6190
6191 int32_t col[3];
6192 /*
6193 if( color < 0 )
6194 {
6195 col[0]=draw_container.color_buffer[0];
6196 col[1]=draw_container.color_buffer[1];
6197 col[2]=draw_container.color_buffer[2];
6198 }
6199 else */
6200 {
6201 col[0]=col[1]=col[2]=color;
6202 }
6203
6204 if(tile > 0) // TILE
6205 {
6206 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
6207 }
6208 else // COMBO
6209 {
6210 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
6211 const int32_t tiletodraw = combo_tile(c, x1, y1);
6212 flip = flip ^ c.flip;
6213
6214 if(!(c.animflags & AF_EDITOR_ONLY))
6215 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
6216 }
6217 if ( !tex_is_bitmap )
6218 {
6219 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
6220 {
6221 Z_message("bitmap->Triangle() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
6222 return; //non power of two error
6223 }
6224 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6225 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(tex_height), col[1] };
6226 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(tex_width), static_cast<float>(tex_height), col[2] };
6227
6228
6229 triangle3d_f(refbmp, polytype, tex, &V1, &V2, &V3);
6230
6231 }
6232
6233 else
6234 {
6235 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", render_source);
6236 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", render_source);
6237 if ( !isPowerOfTwo(utex_h) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", utex_w);
6238 if ( !isPowerOfTwo(utex_w) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", utex_h);
6239
6240 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6241 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(utex_h), col[1] };
6242 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(utex_w), static_cast<float>(utex_h), col[2] };
6243
6244
6245 triangle3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3);
6246
6247 }
6248
6249 if(mustDestroyBmp)
6250 destroy_bitmap(tex);
6251 }
6252
6253
6254 void bmp_do_mode7r(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
6255 {
6256 /*
6257 int32_t layer, int32_t rt, int32_t srcX, int32_t srcY, int32_t srcW, int32_t srcH, int32_t destW, int32_t destH, int32_t angle, int32_t cx, int32_t cy, int32_t space_z, int32_t horizon,
6258 int32_t scale_x, int32_t scale_y){
6259
6260 //sdci[1]=layer
6261 //sdci[2]=bitmap target
6262 //
6263 // -2 is the current Render Target
6264 // -1, this is the screen (framebuf).
6265 // 0: Render target 0
6266 // 1: Render target 1
6267 // 2: Render target 2
6268 // 3: Render target 3
6269 // 4: Render target 4
6270 // 5: Render target 5
6271 // 6: Render target 6
6272 // Otherwise: The pointer to a bitmap.
6273
6274 //sdci[3]=sourcex
6275 //sdci[4]=sourcey
6276 //sdci[5]=sourcew
6277 //sdci[6]=sourceh
6278
6279 //sdci[7]=destw
6280 //sdci[8]=desth
6281 //sdci[9]=angle
6282 //scdi[10] = pivot cx
6283 //sdci[11] = pivot cy
6284 //sdci[12] = space Z
6285 //sdci[13] = horizon
6286 //scdi[14] = scale X
6287 //scdi[15] = scale Y
6288 //sdci[16] = masked?
6289 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
6290
6291
6292
6293 // ZScript-side constant values:
6294 const int32_t BITDX_NORMAL = 0;
6295 const int32_t BITDX_TRANS = 1; //Translucent
6296 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
6297 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
6298 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
6299 //Note: Some modes cannot be combined. if a combination is not supported, an error
6300 // detailing this will be shown in allegro.log.
6301
6302 //scdi[15] = litcolour
6303 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6304 //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
6305
6306 //sdci[16]=mask
6307
6308 */
6309
6310
6311 int32_t bitmapIndex = sdci[2];
6312 int32_t usr_bitmap_index = sdci[2];
6313 //Z_scripterrlog("bitmap index is: %d\n",bitmapIndex);
6314 //Z_scripterrlog("DrawPlane() bitmapIndex is: %d\n", bitmapIndex);
6315
6316 if ( bitmapIndex >= 10000 )
6317 {
6318 bitmapIndex = bitmapIndex / 10000; //reduce if ZScript sent a raw value, such as bitmap = <int32_t> 8;
6319 }
6320 else if ( usr_bitmap_index > 0 )
6321 {
6322 bitmapIndex = usr_bitmap_index;
6323 // Z_scripterrlog("Mode7 is using a user bitmap target, pointer: %d\n", usr_bitmap_index);
6324 yoffset = 0;
6325 }
6326
6327 //rendering mode 7 args
6328 double srcX = sdci[3]/10000.0;
6329 double srcY = sdci[4]/10000.0;
6330 double destX = sdci[5]/10000.0;
6331 double destY = sdci[6]/10000.0;
6332
6333 double destW = sdci[7]/10000.0;
6334 double destH = sdci[8]/10000.0;
6335 double space_z = sdci[9]/10000.0;
6336 double horizon = sdci[10]/10000.0;
6337 double scale_x = sdci[11]/10000.0;
6338 double scale_y = sdci[12]/10000.0;
6339 byte masked = ( sdci[13] ) ? 1 : 0;
6340
6341
6342 int32_t ref = 0;
6343
6344 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
6345 //Do we need to also check the render target and do the same thing if the
6346 //dest == -2 and the render target is not RT_SCREEN?
6347
6348 ref = sdci[DRAWCMD_BMP_TARGET];
6349
6350
6351 if ( ref <= 0 )
6352 {
6353 Z_scripterrlog("bitmap->DrawPlane() wanted to use to an invalid source bitmap id: %d. Aborting.\n", ref);
6354 return;
6355 }
6356 BITMAP *sourceBitmap = resolveScriptingBitmap(ref); //This can be the screen, as -1.
6357
6358 if(!sourceBitmap)
6359 {
6360 Z_message("Warning: %d->DrawPlane() source bitmap contains invalid data or is not initialized.\n", ref);
6361 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6362 return;
6363 }
6364
6365 BITMAP *destBMP=NULL;
6366 switch(bitmapIndex)
6367 {
6368 // Current render target (RT_CURRENT).
6369 // This is the only reason we aren't using resolveScriptingBitmap for the target bitmap. All the other cases should be equivalent.
6370 case -2:
6371 {
6372 int32_t curr_rt = zscriptDrawingRenderTarget->GetCurrentRenderTarget();
6373 if ( curr_rt >= 0 && curr_rt < 7 )
6374 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); //Drawing to the current RenderTarget.
6375 else destBMP = bmp; //screen
6376 break;
6377 }
6378 case -1:
6379 destBMP = bmp; //this is framebuf, by default
6380 break;
6381
6382 //1 through 6 are the old system bitmaps (Render Targets)
6383 case 0:
6384 case 1:
6385 case 2:
6386 case 3:
6387 case 4:
6388 case 5:
6389 case 6:
6390 {
6391 //This gets a render target.
6392 destBMP = zscriptDrawingRenderTarget->GetTargetBitmap(bitmapIndex);
6393 break;
6394 }
6395 //Otherwise, we are using a user-created bitmap, so, get that pointer insted.
6396 default:
6397 {
6398 auto& usr_bitmap = scb.get(usr_bitmap_index);
6399 destBMP = usr_bitmap.u_bmp;
6400 if ( !usr_bitmap.u_bmp )
6401 {
6402 Z_scripterrlog("Target for bitmap->DrawPlane is uninitialised. Aborting.\n");
6403 break;
6404 }
6405 }
6406 }
6407
6408 if (!destBMP)
6409 {
6410 Z_message("Warning: DrawPlane(%d) destination bitmap contains invalid data or is not initialized.\n", bitmapIndex);
6411 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6412 return;
6413 }
6414
6415 //dx = dx + xoffset; //don't do this here!
6416 //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 )
6417 //All of these are a factor of 10000 as fix.
6418 int32_t screen_x = 0; int32_t screen_y = 0;
6419
6420 double distance = 0; double horizontal_scale = 0;
6421
6422 int32_t screen_y_horizon = 0;
6423
6424 double line_dx = 0; double line_dy = 0;
6425
6426 int32_t space_x = 0; int32_t space_y = 0;
6427
6428 for(screen_y = 0; screen_y < destH; screen_y++) //fix, offset by .0000
6429 {
6430 //Calculate the distance of each line from the camera point
6431 screen_y_horizon = screen_y + horizon;
6432
6433 distance = ((space_z * scale_y) / ((screen_y_horizon != 0) ? screen_y_horizon : 1));
6434
6435 //Get the scale of each line based on the distance
6436
6437 horizontal_scale = (distance / (( scale_x != 0 ) ? scale_x : 1));
6438
6439 //There was some math here before I stripped out the rotation step
6440 line_dx = horizontal_scale;
6441 line_dy = 0;
6442
6443 //space_x,space_y - where to grab each scanline from on the space bitmap
6444 space_x = srcX - destW/2.0 * line_dx;
6445 space_y = srcY - distance + destH/2.0 * line_dy;
6446
6447 //Keep blits within the bounds of both bitmaps to avoid crashes
6448 int32_t y1 = srcY+space_y;
6449 int32_t y2 = destY+screen_y;
6450 if(y1 >=0 && y1 <= (sourceBitmap->h-1) && y2 >=0 && y2 <= (destBMP->h-1) )
6451 {
6452 if ( masked ) masked_stretch_blit(sourceBitmap, destBMP, (int32_t)(srcX+space_x), (int32_t)(srcY+space_y),
6453 (int32_t)(line_dx*destW), 1, (int32_t)(screen_x), (int32_t)(screen_y)+yoffset, (int32_t)(destW), 1);
6454 else stretch_blit(sourceBitmap, destBMP, (int32_t)(srcX+space_x), (int32_t)(srcY+space_y),
6455 (int32_t)(line_dx*destW), 1, (int32_t)(screen_x), (int32_t)(screen_y)+yoffset, (int32_t)(destW), 1);
6456 }
6457 }
6458 }
6459
6460
6461 //Draw]()
6462 2062708 void bmp_do_drawbitmapexr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
6463 {
6464 /*
6465 //sdci[1]=layer
6466 //sdci[2]=bitmap target
6467 //
6468 // -2 is the current Render Target
6469 // -1, this is the screen (framebuf).
6470 // 0: Render target 0
6471 // 1: Render target 1
6472 // 2: Render target 2
6473 // 3: Render target 3
6474 // 4: Render target 4
6475 // 5: Render target 5
6476 // 6: Render target 6
6477 // Otherwise: The pointer to a bitmap.
6478
6479 //sdci[3]=sourcex
6480 //sdci[4]=sourcey
6481 //sdci[5]=sourcew
6482 //sdci[6]=sourceh
6483 //sdci[7]=destx
6484 //sdci[8]=desty
6485 //sdci[9]=destw
6486 //sdci[10]=desth
6487 //sdci[11]=rotation/angle
6488 //scdi[12] = pivot cx
6489 //sdci[13] = pivot cy
6490 //scdi[14] = effect flags
6491 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
6492
6493 // ZScript-side constant values:
6494 const int32_t BITDX_NORMAL = 0;
6495 const int32_t BITDX_TRANS = 1; //Translucent
6496 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
6497 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
6498 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
6499 //Note: Some modes cannot be combined. if a combination is not supported, an error
6500 // detailing this will be shown in allegro.log.
6501
6502 //scdi[15] = litcolour
6503 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6504 //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
6505
6506 //sdci[16]=mask
6507
6508 */
6509
6510 2062708 int32_t usr_bitmap_index = sdci[2];
6511 4125416 auto [bitmapIndex, is_user_bitmap] = resolveScriptingBitmapId(usr_bitmap_index);
6512
6513
6514 2062708 int32_t sx = sdci[3]/10000;
6515 2062708 int32_t sy = sdci[4]/10000;
6516 2062708 int32_t sw = sdci[5]/10000;
6517 2062708 int32_t sh = sdci[6]/10000;
6518 2062708 int32_t dx = sdci[7]/10000;
6519 2062708 int32_t dy = sdci[8]/10000;
6520 2062708 int32_t dw = sdci[9]/10000;
6521 2062708 int32_t dh = sdci[10]/10000;
6522 2062708 float rot = sdci[11]/10000;
6523 2062708 int32_t cx = sdci[12]/10000;
6524 2062708 int32_t cy = sdci[13]/10000;
6525 2062708 int32_t mode = sdci[14]/10000;
6526 2062708 int32_t litcolour = sdci[15]/10000;
6527 2062708 bool masked = (sdci[16] != 0);
6528
6529 2062708 int32_t ref = 0;
6530
6531
2/2
✓ Branch 0 taken 267486 times.
✓ Branch 1 taken 1795222 times.
2062708 if (get_qr(qr_BROKEN_SCRIPTS_BITMAP_DRAW_ORIGIN))
6532 {
6533
2/2
✓ Branch 0 taken 95143 times.
✓ Branch 1 taken 172343 times.
267486 if (is_user_bitmap)
6534 172343 yoffset = 0;
6535
6536 267486 dx += xoffset;
6537 267486 dy += yoffset;
6538 267486 }
6539 else
6540 {
6541 1795222 dx += secondary_draw_origin_xoff;
6542 1795222 dy += secondary_draw_origin_yoff;
6543
6544 1795222 sx += xoffset;
6545 1795222 sy += yoffset;
6546 }
6547
6548 2062708 ref = sdci[DRAWCMD_BMP_TARGET];
6549
6550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2062708 times.
2062708 if ( ref <= 0 )
6551 {
6552 Z_scripterrlog("bitmap->blit() wanted to use to an invalid source bitmap id: %d. Aborting.\n", ref);
6553 return;
6554 }
6555 2062708 BITMAP *sourceBitmap = resolveScriptingBitmap(ref); //This can be the screen, as -1.
6556
6557
1/2
✓ Branch 0 taken 2062708 times.
✗ Branch 1 not taken.
2062708 if(!sourceBitmap)
6558 {
6559
6560 Z_message("Warning: blit(%d) source bitmap contains invalid data or is not initialized.\n", ref);
6561 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6562 return;
6563 }
6564
6565 2062708 BITMAP *destBMP=NULL;
6566
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 224018 times.
✓ Branch 2 taken 14218 times.
✓ Branch 3 taken 1824472 times.
2062708 switch(bitmapIndex)
6567 {
6568 // Current render target (RT_CURRENT).
6569 // This is the only reason we aren't using resolveScriptingBitmap for the target bitmap. All the other cases should be equivalent.
6570 case -2:
6571 {
6572 14218 int32_t curr_rt = zscriptDrawingRenderTarget->GetCurrentRenderTarget();
6573
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14218 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14218 if ( curr_rt >= 0 && curr_rt < 7 )
6574 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); //Drawing to the current RenderTarget.
6575 14218 else destBMP = bmp; //screen
6576 14218 break;
6577 }
6578 case -1:
6579 1824472 destBMP = bmp; //this is framebuf, by default
6580 1824472 break;
6581 //zscriptDrawingRenderTarget->SetCurrentRenderTarget(bitmapIndex);
6582 //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
6583 //destBMP = framebuf; //Drawing to the screen.
6584 //break;
6585
6586 //1 through 6 are the old system bitmaps (Render Targets)
6587 case 0:
6588 case 1:
6589 case 2:
6590 case 3:
6591 case 4:
6592 case 5:
6593 case 6:
6594 {
6595 //This gets a render target.
6596 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); break;
6597
6598 //destBMP = zscriptDrawingRenderTarget->GetTargetBitmap(bitmapIndex);
6599 //sdci[18] = bitmapIndex;
6600 break;
6601 }
6602 //Otherwise, we are using a user-created bitmap, so, get that pointer insted.
6603 default:
6604 {
6605 224018 auto& usr_bitmap = scb.get(usr_bitmap_index);
6606 224018 destBMP = usr_bitmap.u_bmp;
6607 //sdci[18] = usr_bitmap_index;
6608
1/2
✓ Branch 0 taken 224018 times.
✗ Branch 1 not taken.
224018 if ( !usr_bitmap.u_bmp )
6609 {
6610 Z_scripterrlog("Target for bitmap->Blit is uninitialised. Aborting.\n");
6611 break;
6612 }
6613 }
6614 224018 }
6615
6616
1/2
✓ Branch 0 taken 2062708 times.
✗ Branch 1 not taken.
2062708 if (!destBMP)
6617 {
6618 Z_message("Warning: blit(%d) destination bitmap contains invalid data or is not initialized.\n", bitmapIndex);
6619 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6620 return;
6621 }
6622
6623
2/2
✓ Branch 0 taken 1511 times.
✓ Branch 1 taken 2061197 times.
2062708 bool stretched = (sw != dw || sh != dh);
6624 2062708 BITMAP* subBmp = 0;
6625
6626
4/4
✓ Branch 0 taken 2061129 times.
✓ Branch 1 taken 1579 times.
✓ Branch 2 taken 25732 times.
✓ Branch 3 taken 2035397 times.
2062708 if(rot != 0 || mode != 0)
6627 {
6628 27311 subBmp = create_bitmap_ex(8,sourceBitmap->w, sourceBitmap->h);//script_drawing_commands.AquireSubBitmap(dw, dh);
6629 27311 clear_bitmap(subBmp);
6630
6631
1/2
✓ Branch 0 taken 27311 times.
✗ Branch 1 not taken.
27311 if(!subBmp)
6632 {
6633
6634 Z_scripterrlog("bitmap->Blit failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
6635 return;
6636 }
6637 27311 }
6638 2062708 BITMAP* sbmp = sourceBitmap;
6639
3/4
✓ Branch 0 taken 2061946 times.
✓ Branch 1 taken 762 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2061946 times.
2062708 if (sx + sw > sbmp->w || sy + sh > sbmp->h)
6640 {
6641 762 sbmp = create_bitmap_ex(8, sw, sh);
6642 762 clear_bitmap(sbmp);
6643 762 blit(sourceBitmap, sbmp, sx, sy, 0, 0, std::min(sourceBitmap->w-sx, sw), std::min(sourceBitmap->h-sy, sh));
6644 762 sx = 0;
6645 762 sy = 0;
6646 762 }
6647 //dx = dx + xoffset; //don't do this here!
6648 //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 )
6649
6650
2/2
✓ Branch 0 taken 2086 times.
✓ Branch 1 taken 2060622 times.
2062708 if(stretched)
6651 {
6652
2/2
✓ Branch 0 taken 1475 times.
✓ Branch 1 taken 611 times.
2086 if(masked)
6653 { //stretched and masked
6654
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 901 times.
1475 if ( rot == 0 )
6655 { //if not rotated
6656
2/22
✗ Branch 0 not taken.
✓ Branch 1 taken 900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 times.
901 switch(mode)
6657 {
6658 case 1:
6659 //transparent
6660 900 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6661 900 draw_trans_sprite(destBMP, subBmp, dx, dy);
6662 900 break;
6663
6664
6665 case 2:
6666 //pivot?
6667 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6668 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6669 //Pivoting requires two more args
6670 break;
6671
6672 case 3:
6673 //pivot + trans
6674 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6675 pivot_sprite_trans(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6676 break;
6677
6678 case 4:
6679 //flip v
6680 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6681 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
6682 break;
6683
6684 case 5:
6685 //trans + v flip
6686 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6687 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
6688 break;
6689
6690 case 6:
6691 //pivot + v flip
6692 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6693 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6694 break;
6695
6696 case 8:
6697 //vlip h
6698 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6699 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
6700 break;
6701
6702 case 9:
6703 //trans + h flip
6704 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6705 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
6706 break;
6707
6708 case 10:
6709 //flip H and pivot
6710 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
6711 //return error cannot pivot and h flip
6712 break;
6713
6714 case 12:
6715 //vh flip
6716 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6717 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
6718 break;
6719
6720 case 13:
6721 //trans + vh flip
6722 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6723 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
6724 break;
6725
6726 case 14:
6727 //pivot and vh flip
6728 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
6729 //return error cannot both pivot and vh flip
6730 break;
6731
6732 case 16:
6733 //lit
6734 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6735 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
6736 break;
6737
6738 case 18:
6739 //pivot, lit
6740 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6741 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
6742 break;
6743
6744 case 20:
6745 //lit + v flip
6746 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6747 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
6748 break;
6749
6750 case 22:
6751 //Pivot, vflip, lit
6752 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6753 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
6754 break;
6755
6756 case 24:
6757 //lit + h flip
6758 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6759 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
6760 break;
6761
6762 case 26:
6763 //pivot + lit + hflip
6764 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
6765 //return error cannot pivot, lit, and flip
6766 break;
6767
6768 case 28:
6769 //lit + vh flip
6770 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6771 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
6772 break;
6773
6774 case 32: //gouraud
6775 //Probably not wort supporting.
6776 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6777 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
6778 break;
6779
6780 case 0:
6781 //no effect
6782 1 masked_stretch_blit(sbmp, destBMP, sx, sy, sw, sh, dx, dy, dw, dh);
6783 1 break;
6784
6785
6786 default:
6787
6788 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
6789
6790
6791 }
6792 901 } //end if not rotated
6793
6794
2/2
✓ Branch 0 taken 901 times.
✓ Branch 1 taken 574 times.
1475 if ( rot != 0 ) //if rotated
6795 {
6796
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 574 times.
✗ Branch 21 not taken.
574 switch(mode)
6797 {
6798 case 1:
6799 //transparent
6800 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6801 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
6802
6803 break;
6804
6805 case 2:
6806 //pivot?
6807 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6808 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6809 //Pivoting requires two more args
6810 break;
6811
6812 case 3:
6813 //pivot + trans
6814 //return an error, cannot both rotate and pivot
6815 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
6816 break;
6817
6818 case 4:
6819 //flip v
6820 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6821 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
6822 break;
6823
6824 case 5:
6825 //trans + v flip
6826 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6827 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
6828 break;
6829
6830 case 6:
6831 //pivot + v flip
6832 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
6833 //return an error, cannot both rotate and pivot
6834 break;
6835
6836 case 8:
6837 //flip h
6838 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
6839 //return an error, cannot both rotate and flip H
6840 break;
6841
6842 case 9:
6843 //trans + h flip
6844 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
6845 //return an error, cannot rotate and flip a trans sprite
6846 break;
6847
6848 case 10:
6849 //flip H and pivot
6850 //return error cannot pivot and h flip
6851 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
6852 break;
6853
6854 case 12:
6855 //vh flip
6856 //return an error, cannot rotate and VH flip a trans sprite
6857 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
6858 break;
6859
6860 case 13:
6861 //trans + vh flip
6862 //return an error, cannot rotate and VH flip a trans sprite
6863 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
6864 break;
6865
6866 case 14:
6867 //pivot and vh flip
6868 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
6869 //return error cannot both pivot and vh flip
6870 break;
6871
6872 case 16:
6873 //lit
6874 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6875 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6876 break;
6877
6878 case 18:
6879 //pivot, lit
6880 //return an error, cannot both rotate and pivot
6881 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
6882 break;
6883
6884 case 20:
6885 //lit + vflip
6886 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6887 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6888 break;
6889
6890 case 22:
6891 //Pivot, vflip, lit
6892 //return an error, cannot both rotate and pivot
6893 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
6894 break;
6895
6896 case 24:
6897 //lit + h flip
6898 //return an error, cannot both rotate and H flip
6899 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
6900 break;
6901
6902 case 26:
6903 //pivot + lit + hflip
6904 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
6905 //return error cannot pivot, lit, and flip
6906 break;
6907
6908 case 28:
6909 //lit + vh flip
6910 //return an error, cannot both rotate and VH flip
6911 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
6912 break;
6913
6914 case 32: //gouraud
6915 //Probably not wort supporting.
6916 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6917 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
6918 break;
6919
6920 case 0:
6921 //no effect.
6922 574 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6923 574 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
6924 574 break;
6925
6926 default:
6927
6928 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
6929
6930 }
6931 574 }
6932 1475 } //end if stretched and masked
6933
6934 else //stretched, not masked
6935 {
6936
6937
6938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 611 times.
611 if ( rot == 0 ) //if not rotated
6939 {
6940
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 611 times.
611 switch(mode)
6941 {
6942 case 1:
6943 //transparent
6944 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6945 draw_trans_sprite(destBMP, subBmp, dx, dy);
6946 break;
6947
6948
6949 case 2:
6950 //pivot?
6951 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6952 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6953 //Pivoting requires two more args
6954 break;
6955
6956 case 3:
6957 //pivot + trans
6958 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6959 pivot_sprite_trans(destBMP, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot));
6960 break;
6961
6962 case 4:
6963 //flip v
6964 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6965 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
6966 break;
6967
6968 case 5:
6969 //trans + v flip
6970 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6971 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
6972 break;
6973
6974 case 6:
6975 //pivot + v flip
6976 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6977 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6978 break;
6979
6980 case 8:
6981 //vlip h
6982 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6983 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
6984 break;
6985
6986 case 9:
6987 //trans + h flip
6988 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6989 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
6990 break;
6991
6992 case 10:
6993 //flip H and pivot
6994 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
6995 //return error cannot pivot and h flip
6996 break;
6997
6998 case 12:
6999 //vh flip
7000 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7001 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
7002 break;
7003
7004 case 13:
7005 //trans + vh flip
7006 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7007 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
7008 break;
7009
7010 case 14:
7011 //pivot and vh flip
7012 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7013 //return error cannot both pivot and vh flip
7014 break;
7015
7016 case 16:
7017 //lit
7018 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7019 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
7020 break;
7021
7022 case 18:
7023 //pivot, lit
7024 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7025 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7026 break;
7027
7028 case 20:
7029 //lit + v flip
7030 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7031 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
7032 break;
7033
7034 case 22:
7035 //Pivot, vflip, lit
7036 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7037 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7038 break;
7039
7040 case 24:
7041 //lit + h flip
7042 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7043 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
7044 break;
7045
7046 case 26:
7047 //pivot + lit + hflip
7048 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
7049 //return error cannot pivot, lit, and flip
7050 break;
7051
7052 case 28:
7053 //lit + vh flip
7054 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7055 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
7056 break;
7057
7058 case 32: //gouraud
7059 //Probably not wort supporting.
7060 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7061 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7062 break;
7063
7064 case 0:
7065 //no effect
7066 611 stretch_blit(sbmp, destBMP, sx, sy, sw, sh, dx, dy, dw, dh);
7067 611 break;
7068
7069
7070 default:
7071
7072 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7073
7074
7075 }
7076 611 } //end if not rotated
7077
7078
1/2
✓ Branch 0 taken 611 times.
✗ Branch 1 not taken.
611 if ( rot != 0 ) //if rotated
7079 {
7080 switch(mode)
7081 {
7082 case 1:
7083 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
7084 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7085
7086 break;
7087
7088 case 2:
7089 //pivot?
7090 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7091 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7092 //Pivoting requires two more args
7093 break;
7094
7095 case 3:
7096 //pivot + trans
7097 //return an error, cannot both rotate and pivot
7098 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7099 break;
7100
7101 case 4:
7102 //flip v
7103 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7104 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7105 break;
7106
7107 case 5:
7108 //trans + v flip
7109 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7110 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7111 break;
7112
7113 case 6:
7114 //pivot + v flip
7115 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7116 //return an error, cannot both rotate and pivot
7117 break;
7118
7119 case 8:
7120 //flip h
7121 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
7122 //return an error, cannot both rotate and flip H
7123 break;
7124
7125 case 9:
7126 //trans + h flip
7127 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
7128 //return an error, cannot rotate and flip a trans sprite
7129 break;
7130
7131 case 10:
7132 //flip H and pivot
7133 //return error cannot pivot and h flip
7134 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7135 break;
7136
7137 case 12:
7138 //vh flip
7139 //return an error, cannot rotate and VH flip a trans sprite
7140 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7141 break;
7142
7143 case 13:
7144 //trans + vh flip
7145 //return an error, cannot rotate and VH flip a trans sprite
7146 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7147 break;
7148
7149 case 14:
7150 //pivot and vh flip
7151 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7152 //return error cannot both pivot and vh flip
7153 break;
7154
7155 case 16:
7156 //lit
7157 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
7158 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7159 break;
7160
7161 case 18:
7162 //pivot, lit
7163 //return an error, cannot both rotate and pivot
7164 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7165 break;
7166
7167 case 20:
7168 //lit + vflip
7169 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
7170 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7171 break;
7172
7173 case 22:
7174 //Pivot, vflip, lit
7175 //return an error, cannot both rotate and pivot
7176 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7177 break;
7178
7179 case 24:
7180 //lit + h flip
7181 //return an error, cannot both rotate and H flip
7182 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
7183 break;
7184
7185 case 26:
7186 //pivot + lit + hflip
7187 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
7188 //return error cannot pivot, lit, and flip
7189 break;
7190
7191 case 28:
7192 //lit + vh flip
7193 //return an error, cannot both rotate and VH flip
7194 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7195 break;
7196
7197 case 32: //gouraud
7198 //Probably not wort supporting.
7199 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7200 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7201 break;
7202
7203 case 0:
7204 //no effect.
7205 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7206 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7207 break;
7208
7209 default:
7210
7211 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7212
7213 }
7214 }
7215
7216 } //end if stretched, but not masked
7217 2086 }
7218 else //not stretched
7219 {
7220
7221
2/2
✓ Branch 0 taken 1982848 times.
✓ Branch 1 taken 77774 times.
2060622 if(masked) //if masked, but not stretched
7222 {
7223
7224
2/2
✓ Branch 0 taken 1005 times.
✓ Branch 1 taken 1981843 times.
1982848 if ( rot == 0 ) //if not rotated
7225 {
7226
2/22
✗ Branch 0 not taken.
✓ Branch 1 taken 19118 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1962725 times.
1981843 switch(mode)
7227 {
7228 case 1:
7229 //transparent
7230 19118 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7231 19118 draw_trans_sprite(destBMP, subBmp, dx, dy);
7232 19118 break;
7233
7234
7235 case 2:
7236 //pivot?
7237 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7238 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7239 //Pivoting requires two more args
7240 break;
7241
7242 case 3:
7243 //pivot + trans
7244 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7245 pivot_sprite_trans(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7246 break;
7247
7248 case 4:
7249 //flip v
7250 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7251 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
7252 break;
7253
7254 case 5:
7255 //trans + v flip
7256 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7257 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
7258 break;
7259
7260 case 6:
7261 //pivot + v flip
7262 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7263 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7264 break;
7265
7266 case 8:
7267 //vlip h
7268 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7269 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
7270 break;
7271
7272 case 9:
7273 //trans + h flip
7274 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7275 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
7276 break;
7277
7278 case 10:
7279 //flip H and pivot
7280 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7281 //return error cannot pivot and h flip
7282 break;
7283
7284 case 12:
7285 //vh flip
7286 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7287 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
7288 break;
7289
7290 case 13:
7291 //trans + vh flip
7292 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7293 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
7294 break;
7295
7296 case 14:
7297 //pivot and vh flip
7298 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7299 //return error cannot both pivot and vh flip
7300 break;
7301
7302 case 16:
7303 //lit
7304 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7305 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
7306 break;
7307
7308 case 18:
7309 //pivot, lit
7310 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7311 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7312 break;
7313
7314 case 20:
7315 //lit + v flip
7316 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7317 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
7318 break;
7319
7320 case 22:
7321 //Pivot, vflip, lit
7322 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7323 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7324 break;
7325
7326 case 24:
7327 //lit + h flip
7328 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7329 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
7330 break;
7331
7332 case 26:
7333 //pivot + lit + hflip
7334 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
7335 //return error cannot pivot, lit, and flip
7336 break;
7337
7338 case 28:
7339 //lit + vh flip
7340 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7341 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
7342 break;
7343
7344 case 32: //gouraud
7345 //Probably not wort supporting.
7346 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7347 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7348 break;
7349
7350 case 0:
7351 //no effect
7352 1962725 masked_blit(sbmp, destBMP, sx, sy, dx, dy, dw, dh);
7353 1962725 break;
7354
7355
7356 default:
7357
7358 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7359
7360
7361 }
7362 1981843 } //end if not rotated
7363
7364
2/2
✓ Branch 0 taken 1981843 times.
✓ Branch 1 taken 1005 times.
1982848 if ( rot != 0 ) //if rotated
7365 {
7366
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 1005 times.
✗ Branch 21 not taken.
1005 switch(mode)
7367 {
7368 case 1:
7369 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); //transparent
7370 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7371
7372 break;
7373
7374 case 2:
7375 //pivot?
7376 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7377 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7378 //Pivoting requires two more args
7379 break;
7380
7381 case 3:
7382 //pivot + trans
7383 //return an error, cannot both rotate and pivot
7384 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7385 break;
7386
7387 case 4:
7388 //flip v
7389 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7390 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7391 break;
7392
7393 case 5:
7394 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip
7395 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7396 break;
7397
7398 case 6:
7399 //pivot + v flip
7400 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7401 //return an error, cannot both rotate and pivot
7402 break;
7403
7404 case 8:
7405 //flip h
7406 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
7407 //return an error, cannot both rotate and flip H
7408 break;
7409
7410 case 9:
7411 //trans + h flip
7412 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
7413 //return an error, cannot rotate and flip a trans sprite
7414 break;
7415
7416 case 10:
7417 //flip H and pivot
7418 //return error cannot pivot and h flip
7419 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7420 break;
7421
7422 case 12:
7423 //vh flip
7424 //return an error, cannot rotate and VH flip a trans sprite
7425 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7426 break;
7427
7428 case 13:
7429 //trans + vh flip
7430 //return an error, cannot rotate and VH flip a trans sprite
7431 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7432 break;
7433
7434 case 14:
7435 //pivot and vh flip
7436 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7437 //return error cannot both pivot and vh flip
7438 break;
7439
7440 case 16:
7441 //lit
7442 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7443 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7444 break;
7445
7446 case 18:
7447 //pivot, lit
7448 //return an error, cannot both rotate and pivot
7449 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7450 break;
7451
7452 case 20:
7453 //lit + vflip
7454 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7455 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7456 break;
7457
7458 case 22:
7459 //Pivot, vflip, lit
7460 //return an error, cannot both rotate and pivot
7461 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7462 break;
7463
7464 case 24:
7465 //lit + h flip
7466 //return an error, cannot both rotate and H flip
7467 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
7468 break;
7469
7470 case 26:
7471 //pivot + lit + hflip
7472 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
7473 //return error cannot pivot, lit, and flip
7474 break;
7475
7476 case 28:
7477 //lit + vh flip
7478 //return an error, cannot both rotate and VH flip
7479 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7480 break;
7481
7482 case 32: //gouraud
7483 //Probably not wort supporting.
7484 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7485 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7486 break;
7487
7488 case 0:
7489 //no effect.
7490 1005 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7491 1005 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7492 1005 break;
7493
7494 default:
7495
7496 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7497
7498 }
7499 1005 } //end rtated, masked
7500 1982848 } //end if masked
7501
7502 else //not masked, and not stretched; just blit
7503 {
7504
7505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77774 times.
77774 if ( rot == 0 ) //if not rotated
7506 {
7507
2/22
✗ Branch 0 not taken.
✓ Branch 1 taken 5714 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 72060 times.
77774 switch(mode)
7508 {
7509 case 1:
7510 //transparent
7511 5714 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7512 5714 draw_trans_sprite(destBMP, subBmp, dx, dy);
7513 5714 break;
7514
7515
7516 case 2:
7517 //pivot?
7518 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7519 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7520 //Pivoting requires two more args
7521 break;
7522
7523 case 3:
7524 //pivot + trans
7525 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7526 pivot_sprite_trans(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7527 break;
7528
7529 case 4:
7530 //flip v
7531 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7532 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
7533 break;
7534
7535 case 5:
7536 //trans + v flip
7537 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7538 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
7539 break;
7540
7541 case 6:
7542 //pivot + v flip
7543 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7544 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7545 break;
7546
7547 case 8:
7548 //vlip h
7549 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7550 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
7551 break;
7552
7553 case 9:
7554 //trans + h flip
7555 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7556 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
7557 break;
7558
7559 case 10:
7560 //flip H and pivot
7561 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7562 //return error cannot pivot and h flip
7563 break;
7564
7565 case 12:
7566 //vh flip
7567 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7568 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
7569 break;
7570
7571 case 13:
7572 //trans + vh flip
7573 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7574 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
7575 break;
7576
7577 case 14:
7578 //pivot and vh flip
7579 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7580 //return error cannot both pivot and vh flip
7581 break;
7582
7583 case 16:
7584 //lit
7585 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7586 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
7587 break;
7588
7589 case 18:
7590 //pivot, lit
7591 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7592 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7593 break;
7594
7595 case 20:
7596 //lit + v flip
7597 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7598 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
7599 break;
7600
7601 case 22:
7602 //Pivot, vflip, lit
7603 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7604 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7605 break;
7606
7607 case 24:
7608 //lit + h flip
7609 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7610 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
7611 break;
7612
7613 case 26:
7614 //pivot + lit + hflip
7615 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
7616 //return error cannot pivot, lit, and flip
7617 break;
7618
7619 case 28:
7620 //lit + vh flip
7621 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7622 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
7623 break;
7624
7625 case 32: //gouraud
7626 //Probably not wort supporting.
7627 //blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7628 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7629 break;
7630
7631 case 0:
7632 //no effect
7633 72060 blit(sbmp, destBMP, sx, sy, dx, dy, dw, dh);
7634 72060 break;
7635
7636
7637 default:
7638
7639 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7640
7641
7642 }
7643 77774 } //end if not rotated
7644
7645
1/2
✓ Branch 0 taken 77774 times.
✗ Branch 1 not taken.
77774 if ( rot != 0 ) //if rotated
7646 {
7647 switch(mode)
7648 {
7649 case 1:
7650 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);//transparent
7651 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7652
7653 break;
7654
7655 case 2:
7656 //pivot?
7657 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7658 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7659 //Pivoting requires two more args
7660 break;
7661
7662 case 3:
7663 //pivot + trans
7664 //return an error, cannot both rotate and pivot
7665 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7666 break;
7667
7668 case 4:
7669 //flip v
7670 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7671 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7672 break;
7673
7674 case 5:
7675 //trans + v flip
7676 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7677 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7678 break;
7679
7680 case 6:
7681 //pivot + v flip
7682 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7683 //return an error, cannot both rotate and pivot
7684 break;
7685
7686 case 8:
7687 //flip h
7688 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
7689 //return an error, cannot both rotate and flip H
7690 break;
7691
7692 case 9:
7693 //trans + h flip
7694 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
7695 //return an error, cannot rotate and flip a trans sprite
7696 break;
7697
7698 case 10:
7699 //flip H and pivot
7700 //return error cannot pivot and h flip
7701 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7702 break;
7703
7704 case 12:
7705 //vh flip
7706 //return an error, cannot rotate and VH flip a trans sprite
7707 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7708 break;
7709
7710 case 13:
7711 //trans + vh flip
7712 //return an error, cannot rotate and VH flip a trans sprite
7713 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7714 break;
7715
7716 case 14:
7717 //pivot and vh flip
7718 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7719 //return error cannot both pivot and vh flip
7720 break;
7721
7722 case 16:
7723 //lit
7724 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7725 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7726 break;
7727
7728 case 18:
7729 //pivot, lit
7730 //return an error, cannot both rotate and pivot
7731 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7732 break;
7733
7734 case 20:
7735 //lit + vflip
7736 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7737 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7738 break;
7739
7740 case 22:
7741 //Pivot, vflip, lit
7742 //return an error, cannot both rotate and pivot
7743 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7744 break;
7745
7746 case 24:
7747 //lit + h flip
7748 //return an error, cannot both rotate and H flip
7749 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
7750 break;
7751
7752 case 26:
7753 //pivot + lit + hflip
7754 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
7755 //return error cannot pivot, lit, and flip
7756 break;
7757
7758 case 28:
7759 //lit + vh flip
7760 //return an error, cannot both rotate and VH flip
7761 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7762 break;
7763
7764 case 32: //gouraud
7765 //Probably not wort supporting.
7766 //blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7767 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7768 break;
7769
7770 case 0:
7771 //no effect.
7772 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7773 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7774 break;
7775
7776 default:
7777
7778 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7779
7780 }
7781 } //end if rotated
7782 } //end if not masked
7783 } //end if not stretched
7784
7785 //cleanup
7786
2/2
✓ Branch 0 taken 27311 times.
✓ Branch 1 taken 2035397 times.
2062708 if(subBmp)
7787 {
7788 //script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap.
7789 27311 destroy_bitmap(subBmp);
7790 27311 }
7791
2/2
✓ Branch 0 taken 762 times.
✓ Branch 1 taken 2061946 times.
2062708 if (sbmp != sourceBitmap)
7792 {
7793 762 destroy_bitmap(sbmp);
7794 762 }
7795 2062708 }
7796
7797
7798
7799 113653 void bmp_do_blittor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
7800 {
7801 /*
7802 //sdci[1]=layer
7803 //sdci[2]=bitmap target
7804 //
7805 // -2 is the current Render Target
7806 // -1, this is the screen (framebuf).
7807 // 0: Render target 0
7808 // 1: Render target 1
7809 // 2: Render target 2
7810 // 3: Render target 3
7811 // 4: Render target 4
7812 // 5: Render target 5
7813 // 6: Render target 6
7814 // Otherwise: The pointer to a bitmap.
7815
7816 //sdci[3]=sourcex
7817 //sdci[4]=sourcey
7818 //sdci[5]=sourcew
7819 //sdci[6]=sourceh
7820 //sdci[7]=destx
7821 //sdci[8]=desty
7822 //sdci[9]=destw
7823 //sdci[10]=desth
7824 //sdci[11]=rotation/angle
7825 //scdi[12] = pivot cx
7826 //sdci[13] = pivot cy
7827 //scdi[14] = effect flags
7828 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
7829
7830 // ZScript-side constant values:
7831 const int32_t BITDX_NORMAL = 0;
7832 const int32_t BITDX_TRANS = 1; //Translucent
7833 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
7834 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
7835 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
7836 //Note: Some modes cannot be combined. if a combination is not supported, an error
7837 // detailing this will be shown in allegro.log.
7838
7839 //scdi[15] = litcolour
7840 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7841 //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
7842
7843 //sdci[16]=mask
7844
7845 */
7846
7847 113653 int32_t srcyoffset = yoffset, srcxoffset = xoffset;
7848
7849 113653 int32_t usr_bitmap_index = sdci[2];
7850 340955 auto [bitmapIndex, is_user_bitmap] = resolveScriptingBitmapId(usr_bitmap_index);
7851
7852 113653 int32_t sx = sdci[3]/10000;
7853 113653 int32_t sy = sdci[4]/10000;
7854 113653 int32_t sw = sdci[5]/10000;
7855 113653 int32_t sh = sdci[6]/10000;
7856 113653 int32_t dx = sdci[7]/10000;
7857 113653 int32_t dy = sdci[8]/10000;
7858 113653 int32_t dw = sdci[9]/10000;
7859 113653 int32_t dh = sdci[10]/10000;
7860 113653 float rot = sdci[11]/10000;
7861 113653 int32_t cx = sdci[12]/10000;
7862 113653 int32_t cy = sdci[13]/10000;
7863 113653 int32_t mode = sdci[14]/10000;
7864 113653 int32_t litcolour = sdci[15]/10000;
7865 113653 bool masked = (sdci[16] != 0);
7866
7867 113653 int32_t ref = 0;
7868
7869
2/2
✓ Branch 0 taken 113649 times.
✓ Branch 1 taken 4 times.
113653 if (get_qr(qr_BROKEN_SCRIPTS_BITMAP_DRAW_ORIGIN))
7870 {
7871
2/2
✓ Branch 0 taken 263 times.
✓ Branch 1 taken 113386 times.
113649 if (is_user_bitmap)
7872 113386 srcyoffset = 0;
7873
2/4
✓ Branch 0 taken 113649 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 113649 times.
113649 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
7874
3/4
✓ Branch 0 taken 113649 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 113646 times.
113649 if ( (bitmapIndex) != -2 && (bitmapIndex) != -1 ) srcyoffset = 0; //Don't crop.
7875
7876 113649 dx += xoffset;
7877 113649 dy += yoffset;
7878
7879 113649 sx += srcxoffset;
7880 113649 sy += srcyoffset;
7881 113649 }
7882 else
7883 {
7884 4 dx += xoffset;
7885 4 dy += yoffset;
7886
7887 4 sx += secondary_draw_origin_xoff;
7888 4 sy += secondary_draw_origin_yoff;
7889 }
7890
7891 113653 ref = sdci[DRAWCMD_BMP_TARGET];
7892
7893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113653 times.
113653 if ( ref <= 0 )
7894 {
7895 Z_scripterrlog("bitmap->blit() wanted to use to an invalid source bitmap id: %d. Aborting.\n", ref);
7896 return;
7897 }
7898 113653 BITMAP *sourceBitmap = resolveScriptingBitmap(ref); //This can be the screen, as -1.
7899
1/2
✓ Branch 0 taken 113653 times.
✗ Branch 1 not taken.
113653 if(!sourceBitmap)
7900 {
7901 Z_message("Warning: blit(%d) source bitmap contains invalid data or is not initialized.\n", ref);
7902 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
7903 return;
7904 }
7905
7906 113653 BITMAP *destBMP=NULL;
7907
7908
3/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 113386 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
113653 switch(bitmapIndex)
7909 {
7910 // Current render target (RT_CURRENT).
7911 // This is the only reason we aren't using resolveScriptingBitmap for the target bitmap. All the other cases should be equivalent.
7912 case -2:
7913 {
7914 int32_t curr_rt = zscriptDrawingRenderTarget->GetCurrentRenderTarget();
7915 if ( curr_rt >= 0 && curr_rt < 7 )
7916 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); //Drawing to the current RenderTarget.
7917 else destBMP = bmp; //screen
7918 break;
7919 }
7920 case -1:
7921 7 destBMP = bmp; //this is framebuf, by default
7922 7 break;
7923 //zscriptDrawingRenderTarget->SetCurrentRenderTarget(bitmapIndex);
7924 //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
7925 //destBMP = framebuf; //Drawing to the screen.
7926 //break;
7927
7928 //1 through 6 are the old system bitmaps (Render Targets)
7929 case 0:
7930 case 1:
7931 case 2:
7932 case 3:
7933 case 4:
7934 case 5:
7935 case 6:
7936 {
7937 //This gets a render target.
7938 //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); break;
7939
7940 520 destBMP = zscriptDrawingRenderTarget->GetTargetBitmap(bitmapIndex);
7941 //sdci[18] = bitmapIndex;
7942 260 break;
7943 }
7944 //Otherwise, we are using a user-created bitmap, so, get that pointer insted.
7945 default:
7946 {
7947 113386 auto& usr_bitmap = scb.get(usr_bitmap_index);
7948 113386 destBMP = usr_bitmap.u_bmp;
7949 //sdci[18] = usr_bitmap_index;
7950
1/2
✓ Branch 0 taken 113386 times.
✗ Branch 1 not taken.
113386 if ( !usr_bitmap.u_bmp )
7951 {
7952 Z_scripterrlog("Target for bitmap->Blit is uninitialised. Aborting.\n");
7953 break;
7954 }
7955 }
7956 113386 }
7957
7958
1/2
✓ Branch 0 taken 113653 times.
✗ Branch 1 not taken.
113653 if (!destBMP)
7959 {
7960 Z_message("Warning: blit(%d) destination bitmap contains invalid data or is not initialized.\n", bitmapIndex);
7961 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
7962 return;
7963 }
7964
7965
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 113343 times.
113653 bool stretched = (sw != dw || sh != dh);
7966
7967 113653 BITMAP* newDest = sourceBitmap;
7968 113653 BITMAP* newSource = destBMP; //Flip them.
7969
7970 113653 BITMAP* subBmp = 0;
7971
7972
2/4
✓ Branch 0 taken 113653 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 113653 times.
113653 if(rot != 0 || mode != 0)
7973 {
7974 subBmp = create_bitmap_ex(8,sourceBitmap->w, sourceBitmap->h);//script_drawing_commands.AquireSubBitmap(dw, dh);
7975 clear_bitmap(subBmp);
7976
7977 if(!subBmp)
7978 {
7979 Z_scripterrlog("bitmap->Blit failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
7980 return;
7981 }
7982 }
7983
7984
3/4
✓ Branch 0 taken 113653 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 113650 times.
113653 if (sx + sw > destBMP->w || sy + sh > destBMP->h)
7985 {
7986 3 newSource = create_bitmap_ex(8, sw, sh);
7987 3 clear_bitmap(newSource);
7988 3 blit(destBMP, newSource, sx, sy, 0, 0, std::min(destBMP->w-sx, sw), std::min(destBMP->h-sy, sh));
7989 3 sx = 0;
7990 3 sy = 0;
7991 3 }
7992 //dx = dx + xoffset; //don't do this here!
7993 //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 )
7994
7995
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 113343 times.
113653 if(stretched)
7996 {
7997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 310 times.
310 if(masked)
7998 { //stretched and masked
7999 if ( rot == 0 )
8000 { //if not rotated
8001 switch(mode)
8002 {
8003 case 1:
8004 //transparent
8005 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8006 draw_trans_sprite(newDest, subBmp, dx, dy);
8007 break;
8008
8009
8010 case 2:
8011 //pivot?
8012 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8013 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8014 //Pivoting requires two more args
8015 break;
8016
8017 case 3:
8018 //pivot + trans
8019 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8020 pivot_sprite_trans(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8021 break;
8022
8023 case 4:
8024 //flip v
8025 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8026 draw_sprite_v_flip(newDest, subBmp, dx, dy);
8027 break;
8028
8029 case 5:
8030 //trans + v flip
8031 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8032 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
8033 break;
8034
8035 case 6:
8036 //pivot + v flip
8037 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8038 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8039 break;
8040
8041 case 8:
8042 //vlip h
8043 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8044 draw_sprite_h_flip(newDest, subBmp, dx, dy);
8045 break;
8046
8047 case 9:
8048 //trans + h flip
8049 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8050 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
8051 break;
8052
8053 case 10:
8054 //flip H and pivot
8055 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8056 //return error cannot pivot and h flip
8057 break;
8058
8059 case 12:
8060 //vh flip
8061 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8062 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
8063 break;
8064
8065 case 13:
8066 //trans + vh flip
8067 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8068 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
8069 break;
8070
8071 case 14:
8072 //pivot and vh flip
8073 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8074 //return error cannot both pivot and vh flip
8075 break;
8076
8077 case 16:
8078 //lit
8079 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8080 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
8081 break;
8082
8083 case 18:
8084 //pivot, lit
8085 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8086 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8087 break;
8088
8089 case 20:
8090 //lit + v flip
8091 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8092 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
8093 break;
8094
8095 case 22:
8096 //Pivot, vflip, lit
8097 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8098 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8099 break;
8100
8101 case 24:
8102 //lit + h flip
8103 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8104 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
8105 break;
8106
8107 case 26:
8108 //pivot + lit + hflip
8109 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
8110 //return error cannot pivot, lit, and flip
8111 break;
8112
8113 case 28:
8114 //lit + vh flip
8115 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8116 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
8117 break;
8118
8119 case 32: //gouraud
8120 //Probably not wort supporting.
8121 //masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8122 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8123 break;
8124
8125 case 0:
8126 //no effect
8127 masked_stretch_blit(newSource, newDest, sx, sy, sw, sh, dx, dy, dw, dh);
8128 break;
8129
8130
8131 default:
8132 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8133
8134
8135 }
8136 } //end if not rotated
8137
8138 if ( rot != 0 ) //if rotated
8139 {
8140 switch(mode)
8141 {
8142 case 1:
8143 //transparent
8144 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8145 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8146
8147 break;
8148
8149 case 2:
8150 //pivot?
8151 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8152 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8153 //Pivoting requires two more args
8154 break;
8155
8156 case 3:
8157 //pivot + trans
8158 //return an error, cannot both rotate and pivot
8159 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8160 break;
8161
8162 case 4:
8163 //flip v
8164 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8165 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8166 break;
8167
8168 case 5:
8169 //trans + v flip
8170 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8171 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8172 break;
8173
8174 case 6:
8175 //pivot + v flip
8176 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8177 //return an error, cannot both rotate and pivot
8178 break;
8179
8180 case 8:
8181 //flip h
8182 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
8183 //return an error, cannot both rotate and flip H
8184 break;
8185
8186 case 9:
8187 //trans + h flip
8188 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
8189 //return an error, cannot rotate and flip a trans sprite
8190 break;
8191
8192 case 10:
8193 //flip H and pivot
8194 //return error cannot pivot and h flip
8195 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8196 break;
8197
8198 case 12:
8199 //vh flip
8200 //return an error, cannot rotate and VH flip a trans sprite
8201 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8202 break;
8203
8204 case 13:
8205 //trans + vh flip
8206 //return an error, cannot rotate and VH flip a trans sprite
8207 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8208 break;
8209
8210 case 14:
8211 //pivot and vh flip
8212 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8213 //return error cannot both pivot and vh flip
8214 break;
8215
8216 case 16:
8217 //lit
8218 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8219 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8220 break;
8221
8222 case 18:
8223 //pivot, lit
8224 //return an error, cannot both rotate and pivot
8225 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8226 break;
8227
8228 case 20:
8229 //lit + vflip
8230 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8231 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8232 break;
8233
8234 case 22:
8235 //Pivot, vflip, lit
8236 //return an error, cannot both rotate and pivot
8237 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8238 break;
8239
8240 case 24:
8241 //lit + h flip
8242 //return an error, cannot both rotate and H flip
8243 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
8244 break;
8245
8246 case 26:
8247 //pivot + lit + hflip
8248 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
8249 //return error cannot pivot, lit, and flip
8250 break;
8251
8252 case 28:
8253 //lit + vh flip
8254 //return an error, cannot both rotate and VH flip
8255 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8256 break;
8257
8258 case 32: //gouraud
8259 //Probably not wort supporting.
8260 //masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8261 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8262 break;
8263
8264 case 0:
8265 //no effect.
8266 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8267 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8268 break;
8269
8270 default:
8271 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8272
8273 }
8274 }
8275 } //end if stretched and masked
8276
8277 else //stretched, not masked
8278 {
8279
8280
8281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 310 times.
310 if ( rot == 0 ) //if not rotated
8282 {
8283
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 310 times.
310 switch(mode)
8284 {
8285 case 1:
8286 //transparent
8287 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8288 draw_trans_sprite(newDest, subBmp, dx, dy);
8289 break;
8290
8291
8292 case 2:
8293 //pivot?
8294 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8295 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8296 //Pivoting requires two more args
8297 break;
8298
8299 case 3:
8300 //pivot + trans
8301 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8302 pivot_sprite_trans(newDest, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot));
8303 break;
8304
8305 case 4:
8306 //flip v
8307 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8308 draw_sprite_v_flip(newDest, subBmp, dx, dy);
8309 break;
8310
8311 case 5:
8312 //trans + v flip
8313 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8314 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
8315 break;
8316
8317 case 6:
8318 //pivot + v flip
8319 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8320 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8321 break;
8322
8323 case 8:
8324 //vlip h
8325 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8326 draw_sprite_h_flip(newDest, subBmp, dx, dy);
8327 break;
8328
8329 case 9:
8330 //trans + h flip
8331 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8332 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
8333 break;
8334
8335 case 10:
8336 //flip H and pivot
8337 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8338 //return error cannot pivot and h flip
8339 break;
8340
8341 case 12:
8342 //vh flip
8343 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8344 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
8345 break;
8346
8347 case 13:
8348 //trans + vh flip
8349 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8350 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
8351 break;
8352
8353 case 14:
8354 //pivot and vh flip
8355 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8356 //return error cannot both pivot and vh flip
8357 break;
8358
8359 case 16:
8360 //lit
8361 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8362 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
8363 break;
8364
8365 case 18:
8366 //pivot, lit
8367 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8368 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8369 break;
8370
8371 case 20:
8372 //lit + v flip
8373 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8374 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
8375 break;
8376
8377 case 22:
8378 //Pivot, vflip, lit
8379 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8380 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8381 break;
8382
8383 case 24:
8384 //lit + h flip
8385 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8386 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
8387 break;
8388
8389 case 26:
8390 //pivot + lit + hflip
8391 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
8392 //return error cannot pivot, lit, and flip
8393 break;
8394
8395 case 28:
8396 //lit + vh flip
8397 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8398 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
8399 break;
8400
8401 case 32: //gouraud
8402 //Probably not wort supporting.
8403 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8404 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8405 break;
8406
8407 case 0:
8408 //no effect
8409 310 stretch_blit(newSource, newDest, sx, sy, sw, sh, dx, dy, dw, dh);
8410 310 break;
8411
8412
8413 default:
8414 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8415
8416
8417 }
8418 310 } //end if not rotated
8419
8420
1/2
✓ Branch 0 taken 310 times.
✗ Branch 1 not taken.
310 if ( rot != 0 ) //if rotated
8421 {
8422 switch(mode)
8423 {
8424 case 1:
8425 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
8426 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8427
8428 break;
8429
8430 case 2:
8431 //pivot?
8432 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8433 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8434 //Pivoting requires two more args
8435 break;
8436
8437 case 3:
8438 //pivot + trans
8439 //return an error, cannot both rotate and pivot
8440 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8441 break;
8442
8443 case 4:
8444 //flip v
8445 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8446 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8447 break;
8448
8449 case 5:
8450 //trans + v flip
8451 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8452 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8453 break;
8454
8455 case 6:
8456 //pivot + v flip
8457 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8458 //return an error, cannot both rotate and pivot
8459 break;
8460
8461 case 8:
8462 //flip h
8463 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
8464 //return an error, cannot both rotate and flip H
8465 break;
8466
8467 case 9:
8468 //trans + h flip
8469 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
8470 //return an error, cannot rotate and flip a trans sprite
8471 break;
8472
8473 case 10:
8474 //flip H and pivot
8475 //return error cannot pivot and h flip
8476 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8477 break;
8478
8479 case 12:
8480 //vh flip
8481 //return an error, cannot rotate and VH flip a trans sprite
8482 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8483 break;
8484
8485 case 13:
8486 //trans + vh flip
8487 //return an error, cannot rotate and VH flip a trans sprite
8488 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8489 break;
8490
8491 case 14:
8492 //pivot and vh flip
8493 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8494 //return error cannot both pivot and vh flip
8495 break;
8496
8497 case 16:
8498 //lit
8499 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
8500 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8501 break;
8502
8503 case 18:
8504 //pivot, lit
8505 //return an error, cannot both rotate and pivot
8506 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8507 break;
8508
8509 case 20:
8510 //lit + vflip
8511 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
8512 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8513 break;
8514
8515 case 22:
8516 //Pivot, vflip, lit
8517 //return an error, cannot both rotate and pivot
8518 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8519 break;
8520
8521 case 24:
8522 //lit + h flip
8523 //return an error, cannot both rotate and H flip
8524 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
8525 break;
8526
8527 case 26:
8528 //pivot + lit + hflip
8529 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
8530 //return error cannot pivot, lit, and flip
8531 break;
8532
8533 case 28:
8534 //lit + vh flip
8535 //return an error, cannot both rotate and VH flip
8536 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8537 break;
8538
8539 case 32: //gouraud
8540 //Probably not wort supporting.
8541 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8542 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8543 break;
8544
8545 case 0:
8546 //no effect.
8547 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8548 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8549 break;
8550
8551 default:
8552 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8553
8554 }
8555 }
8556
8557 } //end if stretched, but not masked
8558 310 }
8559 else //not stretched
8560 {
8561
8562
2/2
✓ Branch 0 taken 113326 times.
✓ Branch 1 taken 17 times.
113343 if(masked) //if masked, but not stretched
8563 {
8564
8565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113326 times.
113326 if ( rot == 0 ) //if not rotated
8566 {
8567
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 113326 times.
113326 switch(mode)
8568 {
8569 case 1:
8570 //transparent
8571 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8572 draw_trans_sprite(newDest, subBmp, dx, dy);
8573 break;
8574
8575
8576 case 2:
8577 //pivot?
8578 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8579 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8580 //Pivoting requires two more args
8581 break;
8582
8583 case 3:
8584 //pivot + trans
8585 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8586 pivot_sprite_trans(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8587 break;
8588
8589 case 4:
8590 //flip v
8591 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8592 draw_sprite_v_flip(newDest, subBmp, dx, dy);
8593 break;
8594
8595 case 5:
8596 //trans + v flip
8597 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8598 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
8599 break;
8600
8601 case 6:
8602 //pivot + v flip
8603 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8604 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8605 break;
8606
8607 case 8:
8608 //vlip h
8609 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8610 draw_sprite_h_flip(newDest, subBmp, dx, dy);
8611 break;
8612
8613 case 9:
8614 //trans + h flip
8615 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8616 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
8617 break;
8618
8619 case 10:
8620 //flip H and pivot
8621 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8622 //return error cannot pivot and h flip
8623 break;
8624
8625 case 12:
8626 //vh flip
8627 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8628 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
8629 break;
8630
8631 case 13:
8632 //trans + vh flip
8633 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8634 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
8635 break;
8636
8637 case 14:
8638 //pivot and vh flip
8639 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8640 //return error cannot both pivot and vh flip
8641 break;
8642
8643 case 16:
8644 //lit
8645 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8646 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
8647 break;
8648
8649 case 18:
8650 //pivot, lit
8651 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8652 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8653 break;
8654
8655 case 20:
8656 //lit + v flip
8657 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8658 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
8659 break;
8660
8661 case 22:
8662 //Pivot, vflip, lit
8663 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8664 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8665 break;
8666
8667 case 24:
8668 //lit + h flip
8669 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8670 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
8671 break;
8672
8673 case 26:
8674 //pivot + lit + hflip
8675 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
8676 //return error cannot pivot, lit, and flip
8677 break;
8678
8679 case 28:
8680 //lit + vh flip
8681 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8682 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
8683 break;
8684
8685 case 32: //gouraud
8686 //Probably not wort supporting.
8687 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8688 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8689 break;
8690
8691 case 0:
8692 //no effect
8693 113326 masked_blit(newSource, newDest, sx, sy, dx, dy, dw, dh);
8694 113326 break;
8695
8696
8697 default:
8698 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8699
8700
8701 }
8702 113326 } //end if not rotated
8703
8704
1/2
✓ Branch 0 taken 113326 times.
✗ Branch 1 not taken.
113326 if ( rot != 0 ) //if rotated
8705 {
8706 switch(mode)
8707 {
8708 case 1:
8709 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); //transparent
8710 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8711
8712 break;
8713
8714 case 2:
8715 //pivot?
8716 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8717 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8718 //Pivoting requires two more args
8719 break;
8720
8721 case 3:
8722 //pivot + trans
8723 //return an error, cannot both rotate and pivot
8724 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8725 break;
8726
8727 case 4:
8728 //flip v
8729 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8730 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8731 break;
8732
8733 case 5:
8734 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip
8735 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8736 break;
8737
8738 case 6:
8739 //pivot + v flip
8740 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8741 //return an error, cannot both rotate and pivot
8742 break;
8743
8744 case 8:
8745 //flip h
8746 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
8747 //return an error, cannot both rotate and flip H
8748 break;
8749
8750 case 9:
8751 //trans + h flip
8752 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
8753 //return an error, cannot rotate and flip a trans sprite
8754 break;
8755
8756 case 10:
8757 //flip H and pivot
8758 //return error cannot pivot and h flip
8759 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8760 break;
8761
8762 case 12:
8763 //vh flip
8764 //return an error, cannot rotate and VH flip a trans sprite
8765 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8766 break;
8767
8768 case 13:
8769 //trans + vh flip
8770 //return an error, cannot rotate and VH flip a trans sprite
8771 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8772 break;
8773
8774 case 14:
8775 //pivot and vh flip
8776 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8777 //return error cannot both pivot and vh flip
8778 break;
8779
8780 case 16:
8781 //lit
8782 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8783 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8784 break;
8785
8786 case 18:
8787 //pivot, lit
8788 //return an error, cannot both rotate and pivot
8789 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8790 break;
8791
8792 case 20:
8793 //lit + vflip
8794 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8795 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8796 break;
8797
8798 case 22:
8799 //Pivot, vflip, lit
8800 //return an error, cannot both rotate and pivot
8801 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8802 break;
8803
8804 case 24:
8805 //lit + h flip
8806 //return an error, cannot both rotate and H flip
8807 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
8808 break;
8809
8810 case 26:
8811 //pivot + lit + hflip
8812 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
8813 //return error cannot pivot, lit, and flip
8814 break;
8815
8816 case 28:
8817 //lit + vh flip
8818 //return an error, cannot both rotate and VH flip
8819 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8820 break;
8821
8822 case 32: //gouraud
8823 //Probably not wort supporting.
8824 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8825 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8826 break;
8827
8828 case 0:
8829 //no effect.
8830 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8831 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8832 break;
8833
8834 default:
8835 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8836
8837 }
8838 } //end rtated, masked
8839 113326 } //end if masked
8840
8841 else //not masked, and not stretched; just blit
8842 {
8843
8844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if ( rot == 0 ) //if not rotated
8845 {
8846
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 17 times.
17 switch(mode)
8847 {
8848 case 1:
8849 //transparent
8850 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8851 draw_trans_sprite(newDest, subBmp, dx, dy);
8852 break;
8853
8854
8855 case 2:
8856 //pivot?
8857 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8858 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8859 //Pivoting requires two more args
8860 break;
8861
8862 case 3:
8863 //pivot + trans
8864 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8865 pivot_sprite_trans(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8866 break;
8867
8868 case 4:
8869 //flip v
8870 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8871 draw_sprite_v_flip(newDest, subBmp, dx, dy);
8872 break;
8873
8874 case 5:
8875 //trans + v flip
8876 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8877 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
8878 break;
8879
8880 case 6:
8881 //pivot + v flip
8882 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8883 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8884 break;
8885
8886 case 8:
8887 //vlip h
8888 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8889 draw_sprite_h_flip(newDest, subBmp, dx, dy);
8890 break;
8891
8892 case 9:
8893 //trans + h flip
8894 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8895 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
8896 break;
8897
8898 case 10:
8899 //flip H and pivot
8900 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8901 //return error cannot pivot and h flip
8902 break;
8903
8904 case 12:
8905 //vh flip
8906 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8907 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
8908 break;
8909
8910 case 13:
8911 //trans + vh flip
8912 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8913 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
8914 break;
8915
8916 case 14:
8917 //pivot and vh flip
8918 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8919 //return error cannot both pivot and vh flip
8920 break;
8921
8922 case 16:
8923 //lit
8924 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8925 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
8926 break;
8927
8928 case 18:
8929 //pivot, lit
8930 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8931 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8932 break;
8933
8934 case 20:
8935 //lit + v flip
8936 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8937 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
8938 break;
8939
8940 case 22:
8941 //Pivot, vflip, lit
8942 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8943 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8944 break;
8945
8946 case 24:
8947 //lit + h flip
8948 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8949 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
8950 break;
8951
8952 case 26:
8953 //pivot + lit + hflip
8954 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
8955 //return error cannot pivot, lit, and flip
8956 break;
8957
8958 case 28:
8959 //lit + vh flip
8960 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8961 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
8962 break;
8963
8964 case 32: //gouraud
8965 //Probably not wort supporting.
8966 //blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8967 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8968 break;
8969
8970 case 0:
8971 //no effect
8972 17 blit(newSource, newDest, sx, sy, dx, dy, dw, dh);
8973 17 break;
8974
8975
8976 default:
8977 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8978
8979
8980 }
8981 17 } //end if not rotated
8982
8983
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if ( rot != 0 ) //if rotated
8984 {
8985 switch(mode)
8986 {
8987 case 1:
8988 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);//transparent
8989 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8990
8991 break;
8992
8993 case 2:
8994 //pivot?
8995 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8996 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8997 //Pivoting requires two more args
8998 break;
8999
9000 case 3:
9001 //pivot + trans
9002 //return an error, cannot both rotate and pivot
9003 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
9004 break;
9005
9006 case 4:
9007 //flip v
9008 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9009 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
9010 break;
9011
9012 case 5:
9013 //trans + v flip
9014 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9015 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
9016 break;
9017
9018 case 6:
9019 //pivot + v flip
9020 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
9021 //return an error, cannot both rotate and pivot
9022 break;
9023
9024 case 8:
9025 //flip h
9026 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
9027 //return an error, cannot both rotate and flip H
9028 break;
9029
9030 case 9:
9031 //trans + h flip
9032 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
9033 //return an error, cannot rotate and flip a trans sprite
9034 break;
9035
9036 case 10:
9037 //flip H and pivot
9038 //return error cannot pivot and h flip
9039 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
9040 break;
9041
9042 case 12:
9043 //vh flip
9044 //return an error, cannot rotate and VH flip a trans sprite
9045 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
9046 break;
9047
9048 case 13:
9049 //trans + vh flip
9050 //return an error, cannot rotate and VH flip a trans sprite
9051 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
9052 break;
9053
9054 case 14:
9055 //pivot and vh flip
9056 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
9057 //return error cannot both pivot and vh flip
9058 break;
9059
9060 case 16:
9061 //lit
9062 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9063 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9064 break;
9065
9066 case 18:
9067 //pivot, lit
9068 //return an error, cannot both rotate and pivot
9069 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
9070 break;
9071
9072 case 20:
9073 //lit + vflip
9074 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9075 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9076 break;
9077
9078 case 22:
9079 //Pivot, vflip, lit
9080 //return an error, cannot both rotate and pivot
9081 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
9082 break;
9083
9084 case 24:
9085 //lit + h flip
9086 //return an error, cannot both rotate and H flip
9087 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
9088 break;
9089
9090 case 26:
9091 //pivot + lit + hflip
9092 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
9093 //return error cannot pivot, lit, and flip
9094 break;
9095
9096 case 28:
9097 //lit + vh flip
9098 //return an error, cannot both rotate and VH flip
9099 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
9100 break;
9101
9102 case 32: //gouraud
9103 //Probably not wort supporting.
9104 //blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9105 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9106 break;
9107
9108 case 0:
9109 //no effect.
9110 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9111 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
9112 break;
9113
9114 default:
9115 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
9116
9117 }
9118 } //end if rotated
9119 } //end if not masked
9120 } //end if not stretched
9121
9122 //cleanup
9123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113653 times.
113653 if(subBmp)
9124 {
9125 //script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap.
9126 destroy_bitmap(subBmp);
9127 }
9128
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 113650 times.
113653 if(newSource != destBMP)
9129 {
9130 3 destroy_bitmap(newSource);
9131 3 }
9132 113653 }
9133
9134 void do_tileblit(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool is_bmp, char const* funcstr)
9135 {
9136 /*
9137 //sdci[1]=layer
9138 //sdci[2]=tile
9139 //sdci[3]=cset
9140 //sdci[4]=sourcex
9141 //sdci[5]=sourcey
9142 //sdci[6]=sourcew
9143 //sdci[7]=sourceh
9144 //sdci[8]=destx
9145 //sdci[9]=desty
9146 //sdci[10]=destw
9147 //sdci[11]=desth
9148 //sdci[12]=rotation/angle
9149 //scdi[13] = pivot cx
9150 //sdci[14] = pivot cy
9151 //scdi[15] = effect flags
9152
9153 // ZScript-side constant values:
9154 const int32_t BITDX_NORMAL = 0;
9155 const int32_t BITDX_TRANS = 1; //Translucent
9156 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
9157 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
9158 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
9159 //Note: Some modes cannot be combined. if a combination is not supported, an error
9160 // detailing this will be shown in allegro.log.
9161
9162 //scdi[16] = litcolour
9163 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9164 //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
9165
9166 //sdci[17]=mask
9167 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
9168
9169 */
9170
9171 int32_t tile = sdci[2]/10000;
9172 int32_t cset = WRAP_CS(sdci[3]/10000);
9173
9174 int32_t sx = sdci[4]/10000;
9175 int32_t sy = sdci[5]/10000;
9176 int32_t sw = sdci[6]/10000;
9177 //Z_scripterrlog("sh is: %d\n",sdci[5]/10000);
9178 int32_t sh = sdci[7]/10000;
9179 //Z_scripterrlog("sh is: %d\n",sdci[6]/10000);
9180 int32_t dx = sdci[8]/10000;
9181 int32_t dy = sdci[9]/10000;
9182 int32_t dw = sdci[10]/10000;
9183 int32_t dh = sdci[11]/10000;
9184 float rot = sdci[12]/10000;
9185 int32_t cx = sdci[13]/10000;
9186 int32_t cy = sdci[14]/10000;
9187 int32_t mode = sdci[15]/10000;
9188 int32_t litcolour = sdci[16]/10000;
9189 bool masked = (sdci[17] != 0);
9190
9191 int32_t ref = 0;
9192
9193 if ( is_bmp && (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
9194 //Do we need to also check the render target and do the same thing if the
9195 //dest == -2 and the render target is not RT_SCREEN?
9196 dx += xoffset;
9197 dy += yoffset;
9198
9199 BITMAP *destbmp = nullptr;
9200 if(is_bmp)
9201 {
9202 ref = sdci[DRAWCMD_BMP_TARGET];
9203
9204 if ( ref <= 0 )
9205 {
9206 Z_scripterrlog("%s wanted to use to an invalid dest bitmap id: %d. Aborting.\n", funcstr, ref);
9207 return;
9208 }
9209 destbmp = resolveScriptingBitmap(ref);
9210 if(!destbmp)
9211 {
9212 Z_message("Warning: %s dest bitmap %d contains invalid data or is not initialized.\n", ref);
9213 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
9214 return;
9215 }
9216 }
9217 else destbmp = bmp;
9218
9219 bool stretched = (sw != dw || sh != dh);
9220
9221 BITMAP* srcbmp = create_bitmap_ex(8, sw, sh);
9222 //Draw tiles to srcbmp
9223 {
9224 clear_bitmap(srcbmp);
9225 int tx = 0, ty = 0;
9226 if(sx < 0)
9227 tx = (sx-15)/16;
9228 else if(sx > 15)
9229 tx = sx/16;
9230 if(sy < 0)
9231 ty = (sy-15)/16;
9232 else if(sy > 15)
9233 ty = sy/16;
9234
9235 int gxoff = -wrap(sx,0,15), gyoff = -wrap(sy,0,15);
9236 for(int ix = 0; ix <= sw; ix += 16)
9237 {
9238 for(int iy = 0; iy <= sh; iy += 16)
9239 {
9240 int t = tile+(tx+ix/16);
9241 int rowdiff = TILEROW(t) - TILEROW(tile);
9242 t += rowdiff * (sh/16) * TILES_PER_ROW;
9243 t += (ty+iy/16)*TILES_PER_ROW;
9244 overtile16(srcbmp, t, ix+gxoff, iy+gyoff, cset, 0);
9245 }
9246 }
9247
9248 sx = sy = 0;
9249 }
9250
9251 BITMAP* subBmp = nullptr;
9252
9253 if(rot != 0 || mode != 0)
9254 {
9255 subBmp = create_bitmap_ex(8,destbmp->w, destbmp->h);//script_drawing_commands.AquireSubBitmap(dw, dh);
9256 clear_bitmap(subBmp);
9257
9258 if(!subBmp)
9259 {
9260 Z_scripterrlog("%s failed to create a sub-bitmap to use for %s. Aborting.\n", funcstr, "rotation");
9261 return;
9262 }
9263 }
9264
9265 //dx = dx + xoffset; //don't do this here!
9266 //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 )
9267
9268 if(stretched)
9269 {
9270 if(masked)
9271 { //stretched and masked
9272 if ( rot == 0 )
9273 { //if not rotated
9274 switch(mode)
9275 {
9276 case 1:
9277 //transparent
9278 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9279 draw_trans_sprite(destbmp, subBmp, dx, dy);
9280 break;
9281
9282
9283 case 2:
9284 //pivot?
9285 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9286 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9287 //Pivoting requires two more args
9288 break;
9289
9290 case 3:
9291 //pivot + trans
9292 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9293 pivot_sprite_trans(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9294 break;
9295
9296 case 4:
9297 //flip v
9298 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9299 draw_sprite_v_flip(destbmp, subBmp, dx, dy);
9300 break;
9301
9302 case 5:
9303 //trans + v flip
9304 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9305 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
9306 break;
9307
9308 case 6:
9309 //pivot + v flip
9310 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9311 pivot_sprite_v_flip(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9312 break;
9313
9314 case 8:
9315 //vlip h
9316 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9317 draw_sprite_h_flip(destbmp, subBmp, dx, dy);
9318 break;
9319
9320 case 9:
9321 //trans + h flip
9322 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9323 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
9324 break;
9325
9326 case 10:
9327 //flip H and pivot
9328 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
9329 //return error cannot pivot and h flip
9330 break;
9331
9332 case 12:
9333 //vh flip
9334 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9335 draw_sprite_vh_flip(destbmp, subBmp, dx, dy);
9336 break;
9337
9338 case 13:
9339 //trans + vh flip
9340 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9341 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
9342 break;
9343
9344 case 14:
9345 //pivot and vh flip
9346 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
9347 //return error cannot both pivot and vh flip
9348 break;
9349
9350 case 16:
9351 //lit
9352 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9353 draw_lit_sprite(destbmp, subBmp, dx, dy, litcolour);
9354 break;
9355
9356 case 18:
9357 //pivot, lit
9358 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9359 pivot_sprite_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9360 break;
9361
9362 case 20:
9363 //lit + v flip
9364 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9365 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
9366 break;
9367
9368 case 22:
9369 //Pivot, vflip, lit
9370 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9371 pivot_sprite_v_flip_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9372 break;
9373
9374 case 24:
9375 //lit + h flip
9376 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9377 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
9378 break;
9379
9380 case 26:
9381 //pivot + lit + hflip
9382 Z_message("Warning: %s cannot both Pivot, Flip, and Lit.\n", funcstr);
9383 //return error cannot pivot, lit, and flip
9384 break;
9385
9386 case 28:
9387 //lit + vh flip
9388 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9389 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
9390 break;
9391
9392 case 32: //gouraud
9393 //Probably not wort supporting.
9394 //masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9395 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9396 break;
9397
9398 case 0:
9399 //no effect
9400 masked_stretch_blit(srcbmp, destbmp, sx, sy, sw, sh, dx, dy, dw, dh);
9401 break;
9402
9403
9404 default:
9405 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
9406
9407
9408 }
9409 } //end if not rotated
9410
9411 if ( rot != 0 ) //if rotated
9412 {
9413 switch(mode)
9414 {
9415 case 1:
9416 //transparent
9417 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9418 rotate_sprite_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9419
9420 break;
9421
9422 case 2:
9423 //pivot?
9424 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9425 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9426 //Pivoting requires two more args
9427 break;
9428
9429 case 3:
9430 //pivot + trans
9431 //return an error, cannot both rotate and pivot
9432 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9433 break;
9434
9435 case 4:
9436 //flip v
9437 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9438 rotate_sprite_v_flip(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9439 break;
9440
9441 case 5:
9442 //trans + v flip
9443 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9444 rotate_sprite_v_flip_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9445 break;
9446
9447 case 6:
9448 //pivot + v flip
9449 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9450 //return an error, cannot both rotate and pivot
9451 break;
9452
9453 case 8:
9454 //flip h
9455 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
9456 //return an error, cannot both rotate and flip H
9457 break;
9458
9459 case 9:
9460 //trans + h flip
9461 Z_message("Warning: %s cannot Rotate and Flip a Trans Sprite.\n", funcstr);
9462 //return an error, cannot rotate and flip a trans sprite
9463 break;
9464
9465 case 10:
9466 //flip H and pivot
9467 //return error cannot pivot and h flip
9468 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
9469 break;
9470
9471 case 12:
9472 //vh flip
9473 //return an error, cannot rotate and VH flip a trans sprite
9474 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
9475 break;
9476
9477 case 13:
9478 //trans + vh flip
9479 //return an error, cannot rotate and VH flip a trans sprite
9480 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
9481 break;
9482
9483 case 14:
9484 //pivot and vh flip
9485 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9486 //return error cannot both pivot and vh flip
9487 break;
9488
9489 case 16:
9490 //lit
9491 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9492 rotate_sprite_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9493 break;
9494
9495 case 18:
9496 //pivot, lit
9497 //return an error, cannot both rotate and pivot
9498 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9499 break;
9500
9501 case 20:
9502 //lit + vflip
9503 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9504 rotate_sprite_v_flip_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9505 break;
9506
9507 case 22:
9508 //Pivot, vflip, lit
9509 //return an error, cannot both rotate and pivot
9510 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9511 break;
9512
9513 case 24:
9514 //lit + h flip
9515 //return an error, cannot both rotate and H flip
9516 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
9517 break;
9518
9519 case 26:
9520 //pivot + lit + hflip
9521 Z_message("Warning: %s cannot both Pivot and Flip a Lit Sprite.\n", funcstr);
9522 //return error cannot pivot, lit, and flip
9523 break;
9524
9525 case 28:
9526 //lit + vh flip
9527 //return an error, cannot both rotate and VH flip
9528 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
9529 break;
9530
9531 case 32: //gouraud
9532 //Probably not wort supporting.
9533 //masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9534 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9535 break;
9536
9537 case 0:
9538 //no effect.
9539 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9540 rotate_sprite(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9541 break;
9542
9543 default:
9544 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
9545
9546 }
9547 }
9548 } //end if stretched and masked
9549
9550 else //stretched, not masked
9551 {
9552
9553
9554 if ( rot == 0 ) //if not rotated
9555 {
9556 switch(mode)
9557 {
9558 case 1:
9559 //transparent
9560 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9561 draw_trans_sprite(destbmp, subBmp, dx, dy);
9562 break;
9563
9564
9565 case 2:
9566 //pivot?
9567 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9568 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9569 //Pivoting requires two more args
9570 break;
9571
9572 case 3:
9573 //pivot + trans
9574 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9575 pivot_sprite_trans(destbmp, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot));
9576 break;
9577
9578 case 4:
9579 //flip v
9580 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9581 draw_sprite_v_flip(destbmp, subBmp, dx, dy);
9582 break;
9583
9584 case 5:
9585 //trans + v flip
9586 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9587 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
9588 break;
9589
9590 case 6:
9591 //pivot + v flip
9592 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9593 pivot_sprite_v_flip(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9594 break;
9595
9596 case 8:
9597 //vlip h
9598 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9599 draw_sprite_h_flip(destbmp, subBmp, dx, dy);
9600 break;
9601
9602 case 9:
9603 //trans + h flip
9604 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9605 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
9606 break;
9607
9608 case 10:
9609 //flip H and pivot
9610 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
9611 //return error cannot pivot and h flip
9612 break;
9613
9614 case 12:
9615 //vh flip
9616 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9617 draw_sprite_vh_flip(destbmp, subBmp, dx, dy);
9618 break;
9619
9620 case 13:
9621 //trans + vh flip
9622 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9623 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
9624 break;
9625
9626 case 14:
9627 //pivot and vh flip
9628 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
9629 //return error cannot both pivot and vh flip
9630 break;
9631
9632 case 16:
9633 //lit
9634 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9635 draw_lit_sprite(destbmp, subBmp, dx, dy, litcolour);
9636 break;
9637
9638 case 18:
9639 //pivot, lit
9640 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9641 pivot_sprite_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9642 break;
9643
9644 case 20:
9645 //lit + v flip
9646 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9647 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
9648 break;
9649
9650 case 22:
9651 //Pivot, vflip, lit
9652 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9653 pivot_sprite_v_flip_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9654 break;
9655
9656 case 24:
9657 //lit + h flip
9658 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9659 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
9660 break;
9661
9662 case 26:
9663 //pivot + lit + hflip
9664 Z_message("Warning: %s cannot both Pivot, Flip, and Lit.\n", funcstr);
9665 //return error cannot pivot, lit, and flip
9666 break;
9667
9668 case 28:
9669 //lit + vh flip
9670 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9671 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
9672 break;
9673
9674 case 32: //gouraud
9675 //Probably not wort supporting.
9676 //stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9677 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9678 break;
9679
9680 case 0:
9681 //no effect
9682 stretch_blit(srcbmp, destbmp, sx, sy, sw, sh, dx, dy, dw, dh);
9683 break;
9684
9685
9686 default:
9687 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
9688
9689
9690 }
9691 } //end if not rotated
9692
9693 if ( rot != 0 ) //if rotated
9694 {
9695 switch(mode)
9696 {
9697 case 1:
9698 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
9699 rotate_sprite_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9700
9701 break;
9702
9703 case 2:
9704 //pivot?
9705 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9706 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9707 //Pivoting requires two more args
9708 break;
9709
9710 case 3:
9711 //pivot + trans
9712 //return an error, cannot both rotate and pivot
9713 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9714 break;
9715
9716 case 4:
9717 //flip v
9718 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9719 rotate_sprite_v_flip(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9720 break;
9721
9722 case 5:
9723 //trans + v flip
9724 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9725 rotate_sprite_v_flip_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9726 break;
9727
9728 case 6:
9729 //pivot + v flip
9730 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9731 //return an error, cannot both rotate and pivot
9732 break;
9733
9734 case 8:
9735 //flip h
9736 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
9737 //return an error, cannot both rotate and flip H
9738 break;
9739
9740 case 9:
9741 //trans + h flip
9742 Z_message("Warning: %s cannot Rotate and Flip a Trans Sprite.\n", funcstr);
9743 //return an error, cannot rotate and flip a trans sprite
9744 break;
9745
9746 case 10:
9747 //flip H and pivot
9748 //return error cannot pivot and h flip
9749 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
9750 break;
9751
9752 case 12:
9753 //vh flip
9754 //return an error, cannot rotate and VH flip a trans sprite
9755 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
9756 break;
9757
9758 case 13:
9759 //trans + vh flip
9760 //return an error, cannot rotate and VH flip a trans sprite
9761 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
9762 break;
9763
9764 case 14:
9765 //pivot and vh flip
9766 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9767 //return error cannot both pivot and vh flip
9768 break;
9769
9770 case 16:
9771 //lit
9772 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
9773 rotate_sprite_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9774 break;
9775
9776 case 18:
9777 //pivot, lit
9778 //return an error, cannot both rotate and pivot
9779 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9780 break;
9781
9782 case 20:
9783 //lit + vflip
9784 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
9785 rotate_sprite_v_flip_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9786 break;
9787
9788 case 22:
9789 //Pivot, vflip, lit
9790 //return an error, cannot both rotate and pivot
9791 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9792 break;
9793
9794 case 24:
9795 //lit + h flip
9796 //return an error, cannot both rotate and H flip
9797 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
9798 break;
9799
9800 case 26:
9801 //pivot + lit + hflip
9802 Z_message("Warning: %s cannot both Pivot and Flip a Lit Sprite.\n", funcstr);
9803 //return error cannot pivot, lit, and flip
9804 break;
9805
9806 case 28:
9807 //lit + vh flip
9808 //return an error, cannot both rotate and VH flip
9809 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
9810 break;
9811
9812 case 32: //gouraud
9813 //Probably not wort supporting.
9814 //stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9815 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9816 break;
9817
9818 case 0:
9819 //no effect.
9820 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9821 rotate_sprite(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9822 break;
9823
9824 default:
9825 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
9826
9827 }
9828 }
9829
9830 } //end if stretched, but not masked
9831 }
9832 else //not stretched
9833 {
9834
9835 if(masked) //if masked, but not stretched
9836 {
9837
9838 if ( rot == 0 ) //if not rotated
9839 {
9840 switch(mode)
9841 {
9842 case 1:
9843 //transparent
9844 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9845 draw_trans_sprite(destbmp, subBmp, dx, dy);
9846 break;
9847
9848
9849 case 2:
9850 //pivot?
9851 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9852 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9853 //Pivoting requires two more args
9854 break;
9855
9856 case 3:
9857 //pivot + trans
9858 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9859 pivot_sprite_trans(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9860 break;
9861
9862 case 4:
9863 //flip v
9864 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9865 draw_sprite_v_flip(destbmp, subBmp, dx, dy);
9866 break;
9867
9868 case 5:
9869 //trans + v flip
9870 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9871 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
9872 break;
9873
9874 case 6:
9875 //pivot + v flip
9876 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9877 pivot_sprite_v_flip(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9878 break;
9879
9880 case 8:
9881 //vlip h
9882 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9883 draw_sprite_h_flip(destbmp, subBmp, dx, dy);
9884 break;
9885
9886 case 9:
9887 //trans + h flip
9888 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9889 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
9890 break;
9891
9892 case 10:
9893 //flip H and pivot
9894 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
9895 //return error cannot pivot and h flip
9896 break;
9897
9898 case 12:
9899 //vh flip
9900 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9901 draw_sprite_vh_flip(destbmp, subBmp, dx, dy);
9902 break;
9903
9904 case 13:
9905 //trans + vh flip
9906 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9907 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
9908 break;
9909
9910 case 14:
9911 //pivot and vh flip
9912 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
9913 //return error cannot both pivot and vh flip
9914 break;
9915
9916 case 16:
9917 //lit
9918 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9919 draw_lit_sprite(destbmp, subBmp, dx, dy, litcolour);
9920 break;
9921
9922 case 18:
9923 //pivot, lit
9924 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9925 pivot_sprite_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9926 break;
9927
9928 case 20:
9929 //lit + v flip
9930 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9931 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
9932 break;
9933
9934 case 22:
9935 //Pivot, vflip, lit
9936 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9937 pivot_sprite_v_flip_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9938 break;
9939
9940 case 24:
9941 //lit + h flip
9942 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9943 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
9944 break;
9945
9946 case 26:
9947 //pivot + lit + hflip
9948 Z_message("Warning: %s cannot both Pivot, Flip, and Lit.\n", funcstr);
9949 //return error cannot pivot, lit, and flip
9950 break;
9951
9952 case 28:
9953 //lit + vh flip
9954 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9955 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
9956 break;
9957
9958 case 32: //gouraud
9959 //Probably not wort supporting.
9960 //stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9961 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9962 break;
9963
9964 case 0:
9965 //no effect
9966 masked_blit(srcbmp, destbmp, sx, sy, dx, dy, dw, dh);
9967 break;
9968
9969
9970 default:
9971 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
9972
9973
9974 }
9975 } //end if not rotated
9976
9977 if ( rot != 0 ) //if rotated
9978 {
9979 switch(mode)
9980 {
9981 case 1:
9982 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh); //transparent
9983 rotate_sprite_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9984
9985 break;
9986
9987 case 2:
9988 //pivot?
9989 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9990 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9991 //Pivoting requires two more args
9992 break;
9993
9994 case 3:
9995 //pivot + trans
9996 //return an error, cannot both rotate and pivot
9997 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9998 break;
9999
10000 case 4:
10001 //flip v
10002 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10003 rotate_sprite_v_flip(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10004 break;
10005
10006 case 5:
10007 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip
10008 rotate_sprite_v_flip_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10009 break;
10010
10011 case 6:
10012 //pivot + v flip
10013 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10014 //return an error, cannot both rotate and pivot
10015 break;
10016
10017 case 8:
10018 //flip h
10019 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
10020 //return an error, cannot both rotate and flip H
10021 break;
10022
10023 case 9:
10024 //trans + h flip
10025 Z_message("Warning: %s cannot Rotate and Flip a Trans Sprite.\n", funcstr);
10026 //return an error, cannot rotate and flip a trans sprite
10027 break;
10028
10029 case 10:
10030 //flip H and pivot
10031 //return error cannot pivot and h flip
10032 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
10033 break;
10034
10035 case 12:
10036 //vh flip
10037 //return an error, cannot rotate and VH flip a trans sprite
10038 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
10039 break;
10040
10041 case 13:
10042 //trans + vh flip
10043 //return an error, cannot rotate and VH flip a trans sprite
10044 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
10045 break;
10046
10047 case 14:
10048 //pivot and vh flip
10049 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10050 //return error cannot both pivot and vh flip
10051 break;
10052
10053 case 16:
10054 //lit
10055 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10056 rotate_sprite_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
10057 break;
10058
10059 case 18:
10060 //pivot, lit
10061 //return an error, cannot both rotate and pivot
10062 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10063 break;
10064
10065 case 20:
10066 //lit + vflip
10067 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10068 rotate_sprite_v_flip_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
10069 break;
10070
10071 case 22:
10072 //Pivot, vflip, lit
10073 //return an error, cannot both rotate and pivot
10074 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10075 break;
10076
10077 case 24:
10078 //lit + h flip
10079 //return an error, cannot both rotate and H flip
10080 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
10081 break;
10082
10083 case 26:
10084 //pivot + lit + hflip
10085 Z_message("Warning: %s cannot both Pivot and Flip a Lit Sprite.\n", funcstr);
10086 //return error cannot pivot, lit, and flip
10087 break;
10088
10089 case 28:
10090 //lit + vh flip
10091 //return an error, cannot both rotate and VH flip
10092 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
10093 break;
10094
10095 case 32: //gouraud
10096 //Probably not wort supporting.
10097 //stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
10098 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
10099 break;
10100
10101 case 0:
10102 //no effect.
10103 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10104 rotate_sprite(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10105 break;
10106
10107 default:
10108 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
10109
10110 }
10111 } //end rtated, masked
10112 } //end if masked
10113
10114 else //not masked, and not stretched; just blit
10115 {
10116
10117 if ( rot == 0 ) //if not rotated
10118 {
10119 switch(mode)
10120 {
10121 case 1:
10122 //transparent
10123 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10124 draw_trans_sprite(destbmp, subBmp, dx, dy);
10125 break;
10126
10127
10128 case 2:
10129 //pivot?
10130 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10131 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
10132 //Pivoting requires two more args
10133 break;
10134
10135 case 3:
10136 //pivot + trans
10137 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10138 pivot_sprite_trans(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
10139 break;
10140
10141 case 4:
10142 //flip v
10143 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10144 draw_sprite_v_flip(destbmp, subBmp, dx, dy);
10145 break;
10146
10147 case 5:
10148 //trans + v flip
10149 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10150 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
10151 break;
10152
10153 case 6:
10154 //pivot + v flip
10155 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10156 pivot_sprite_v_flip(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
10157 break;
10158
10159 case 8:
10160 //vlip h
10161 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10162 draw_sprite_h_flip(destbmp, subBmp, dx, dy);
10163 break;
10164
10165 case 9:
10166 //trans + h flip
10167 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10168 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
10169 break;
10170
10171 case 10:
10172 //flip H and pivot
10173 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
10174 //return error cannot pivot and h flip
10175 break;
10176
10177 case 12:
10178 //vh flip
10179 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10180 draw_sprite_vh_flip(destbmp, subBmp, dx, dy);
10181 break;
10182
10183 case 13:
10184 //trans + vh flip
10185 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10186 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
10187 break;
10188
10189 case 14:
10190 //pivot and vh flip
10191 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
10192 //return error cannot both pivot and vh flip
10193 break;
10194
10195 case 16:
10196 //lit
10197 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10198 draw_lit_sprite(destbmp, subBmp, dx, dy, litcolour);
10199 break;
10200
10201 case 18:
10202 //pivot, lit
10203 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10204 pivot_sprite_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
10205 break;
10206
10207 case 20:
10208 //lit + v flip
10209 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10210 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
10211 break;
10212
10213 case 22:
10214 //Pivot, vflip, lit
10215 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10216 pivot_sprite_v_flip_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
10217 break;
10218
10219 case 24:
10220 //lit + h flip
10221 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10222 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
10223 break;
10224
10225 case 26:
10226 //pivot + lit + hflip
10227 Z_message("Warning: %s cannot both Pivot, Flip, and Lit.\n", funcstr);
10228 //return error cannot pivot, lit, and flip
10229 break;
10230
10231 case 28:
10232 //lit + vh flip
10233 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10234 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
10235 break;
10236
10237 case 32: //gouraud
10238 //Probably not wort supporting.
10239 //blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10240 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
10241 break;
10242
10243 case 0:
10244 //no effect
10245 blit(srcbmp, destbmp, sx, sy, dx, dy, dw, dh);
10246 break;
10247
10248
10249 default:
10250 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
10251
10252
10253 }
10254 } //end if not rotated
10255
10256 if ( rot != 0 ) //if rotated
10257 {
10258 switch(mode)
10259 {
10260 case 1:
10261 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);//transparent
10262 rotate_sprite_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10263
10264 break;
10265
10266 case 2:
10267 //pivot?
10268 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10269 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
10270 //Pivoting requires two more args
10271 break;
10272
10273 case 3:
10274 //pivot + trans
10275 //return an error, cannot both rotate and pivot
10276 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10277 break;
10278
10279 case 4:
10280 //flip v
10281 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10282 rotate_sprite_v_flip(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10283 break;
10284
10285 case 5:
10286 //trans + v flip
10287 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10288 rotate_sprite_v_flip_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10289 break;
10290
10291 case 6:
10292 //pivot + v flip
10293 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10294 //return an error, cannot both rotate and pivot
10295 break;
10296
10297 case 8:
10298 //flip h
10299 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
10300 //return an error, cannot both rotate and flip H
10301 break;
10302
10303 case 9:
10304 //trans + h flip
10305 Z_message("Warning: %s cannot Rotate and Flip a Trans Sprite.\n", funcstr);
10306 //return an error, cannot rotate and flip a trans sprite
10307 break;
10308
10309 case 10:
10310 //flip H and pivot
10311 //return error cannot pivot and h flip
10312 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
10313 break;
10314
10315 case 12:
10316 //vh flip
10317 //return an error, cannot rotate and VH flip a trans sprite
10318 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
10319 break;
10320
10321 case 13:
10322 //trans + vh flip
10323 //return an error, cannot rotate and VH flip a trans sprite
10324 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
10325 break;
10326
10327 case 14:
10328 //pivot and vh flip
10329 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10330 //return error cannot both pivot and vh flip
10331 break;
10332
10333 case 16:
10334 //lit
10335 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10336 rotate_sprite_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
10337 break;
10338
10339 case 18:
10340 //pivot, lit
10341 //return an error, cannot both rotate and pivot
10342 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10343 break;
10344
10345 case 20:
10346 //lit + vflip
10347 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10348 rotate_sprite_v_flip_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
10349 break;
10350
10351 case 22:
10352 //Pivot, vflip, lit
10353 //return an error, cannot both rotate and pivot
10354 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10355 break;
10356
10357 case 24:
10358 //lit + h flip
10359 //return an error, cannot both rotate and H flip
10360 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
10361 break;
10362
10363 case 26:
10364 //pivot + lit + hflip
10365 Z_message("Warning: %s cannot both Pivot and Flip a Lit Sprite.\n", funcstr);
10366 //return error cannot pivot, lit, and flip
10367 break;
10368
10369 case 28:
10370 //lit + vh flip
10371 //return an error, cannot both rotate and VH flip
10372 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
10373 break;
10374
10375 case 32: //gouraud
10376 //Probably not wort supporting.
10377 //blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10378 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
10379 break;
10380
10381 case 0:
10382 //no effect.
10383 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10384 rotate_sprite(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10385 break;
10386
10387 default:
10388 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
10389
10390 }
10391 } //end if rotated
10392 } //end if not masked
10393 } //end if not stretched
10394
10395 //cleanup
10396 if(subBmp)
10397 {
10398 //script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap.
10399 destroy_bitmap(subBmp);
10400 }
10401 destroy_bitmap(srcbmp);
10402 }
10403
10404 void do_comboblit(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool is_bmp)
10405 {
10406 //sdci[2]: combo -> tile
10407 int cid = sdci[2]/10000;
10408 if(unsigned(cid) >= MAXCOMBOS)
10409 {
10410 Z_scripterrlog("ComboBlit tried to draw invalid combo id '%d'\n", cid);
10411 return;
10412 }
10413 sdci[2] = GET_DRAWING_COMBO(cid).tile * 10000;
10414 do_tileblit(bmp, sdci, xoffset, yoffset, is_bmp, "ComboBlit()");
10415 }
10416
10417 void bmp_do_drawquad3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
10418 {
10419
10420 //sdci[1]=layer
10421 //sdci[2]=pos[12]
10422 //sdci[3]=uv[8]
10423 //sdci[4]=color[4]
10424 //sdci[5]=size[2]
10425 //sdci[6]=flip
10426 //sdci[7]=tile/combo
10427 //sdci[8]=polytype
10428 //sdci[9] = other bitmap as texture
10429 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
10430 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
10431 {
10432 Z_scripterrlog("bitmap->Quad3D() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
10433 return;
10434 }
10435 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10436 if ( refbmp == NULL ) return;
10437
10438 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
10439
10440 if(!v_ptr)
10441 {
10442 al_trace("Quad3d: Vector pointer is null! Internal error. \n");
10443 return;
10444 }
10445
10446 std::vector<int32_t> &v = *v_ptr;
10447
10448 if(v.empty())
10449 return;
10450
10451 int32_t* pos = &v[0];
10452 int32_t* uv = &v[12];
10453 int32_t* col = &v[20];
10454 int32_t* size = &v[24];
10455
10456 int32_t w = size[0]; //magic numerical constants... yuck.
10457 int32_t h = size[1];
10458 int32_t flip = (sdci[6]/10000)&3;
10459 int32_t tile = sdci[7]/10000;
10460 int32_t polytype = sdci[8]/10000;
10461 int32_t quad_render_source = sdci[9];
10462 Z_scripterrlog("Quad3D texture is %d\n", quad_render_source);
10463
10464 polytype = vbound(polytype, 0, 14);
10465
10466 int32_t tex_width = w*16;
10467 int32_t tex_height = h*16;
10468
10469 bool mustDestroyBmp = false;
10470 BITMAP *tex=NULL;
10471
10472
10473 bool tex_is_bitmap = ( sdci[9] != 0 );
10474 //Z_scripterrlog("sdci[9] is %d\n", quad_render_source);
10475 //Z_scripterrlog("sdci[DRAWCMD_BMP_TARGET] is %d\n", sdci[DRAWCMD_BMP_TARGET]);
10476 BITMAP *bmptexture;
10477
10478 if ( tex_is_bitmap ) bmptexture = resolveScriptingBitmap(quad_render_source);
10479
10480 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
10481
10482
10483 if ( !tex_is_bitmap )
10484 {
10485 tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
10486
10487 if(!tex)
10488 {
10489 mustDestroyBmp = true;
10490 tex = create_bitmap_ex(8, tex_width, tex_height);
10491 clear_bitmap(tex);
10492 }
10493 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
10494 {
10495 Z_message("Quad3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
10496 return; //non power of two error
10497 }
10498 if(tile > 0) // TILE
10499 {
10500 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
10501 }
10502 else // COMBO
10503 {
10504 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
10505 const int32_t tiletodraw = combo_tile(c, 0, 0);
10506 flip = flip ^ c.flip;
10507
10508 if(!(c.animflags & AF_EDITOR_ONLY))
10509 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
10510 }
10511
10512 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
10513 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
10514 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
10515 V3D_f V4 = { static_cast<float>(pos[9]+xoffset), static_cast<float>(pos[10]+yoffset), static_cast<float>(pos[11]), static_cast<float>(uv[6]), static_cast<float>(uv[7]), col[3] };
10516
10517 quad3d_f(refbmp, polytype, tex, &V1, &V2, &V3, &V4);
10518 if(mustDestroyBmp)
10519 destroy_bitmap(tex);
10520 }
10521 else
10522 {
10523
10524 if ( !bmptexture )
10525 {
10526 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Quad3D()");
10527 tex_is_bitmap = 0;
10528 return;
10529 }
10530 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
10531 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
10532 if ( !isPowerOfTwo(h) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", h);
10533 if ( !isPowerOfTwo(w) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", w);
10534
10535 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
10536 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
10537 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
10538 V3D_f V4 = { static_cast<float>(pos[9]+xoffset), static_cast<float>(pos[10]+yoffset), static_cast<float>(pos[11]), static_cast<float>(uv[6]), static_cast<float>(uv[7]), col[3] };
10539
10540 BITMAP *foo = create_bitmap_ex(8, 256, 176);
10541
10542 //quad3d_f(refbmp, polytype, foo, &V1, &V2, &V3, &V4);
10543 quad3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3, &V4);
10544 destroy_bitmap(foo);
10545
10546 }
10547
10548
10549
10550 }
10551
10552
10553
10554 void bmp_do_drawtriangle3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
10555 {
10556 //sdci[1]=layer
10557 //sdci[2]=pos[9]
10558 //sdci[3]=uv[6]
10559 //sdci[4]=color[3]
10560 //sdci[5]=size[2]
10561 //sdci[6]=flip
10562 //sdci[7]=tile/combo
10563 //sdci[8]=polytype
10564 //sdci[9] bitmap as texture
10565 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
10566 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
10567 {
10568 Z_scripterrlog("bitmap->Triangle3D() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
10569 return;
10570 }
10571 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10572 if ( refbmp == NULL ) return;
10573
10574 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
10575
10576 if(!v_ptr)
10577 {
10578 al_trace("bitmap->Triangle3d: Vector pointer is null! Internal error. \n");
10579 return;
10580 }
10581
10582 std::vector<int32_t> &v = *v_ptr;
10583
10584 if(v.empty())
10585 return;
10586
10587 int32_t* pos = &v[0];
10588 int32_t* uv = &v[9];
10589 int32_t* col = &v[15];
10590 int32_t* size = &v[18];
10591
10592 int32_t w = size[0]; //magic numerical constants... yuck.
10593 int32_t h = size[1];
10594 int32_t flip = (sdci[6]/10000)&3;
10595 int32_t tile = sdci[7]/10000;
10596 int32_t polytype = sdci[8]/10000;
10597 int32_t quad_render_source = sdci[9];
10598 polytype = vbound(polytype, 0, 14);
10599
10600 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
10601 {
10602 Z_message("bitmap->Triangle3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
10603 return; //non power of two error
10604 }
10605
10606 int32_t tex_width = w*16;
10607 int32_t tex_height = h*16;
10608
10609 bool mustDestroyBmp = false;
10610 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
10611
10612 if(!tex)
10613 {
10614 mustDestroyBmp = true;
10615 tex = create_bitmap_ex(8, tex_width, tex_height);
10616 clear_bitmap(tex);
10617 }
10618
10619 bool tex_is_bitmap = ( sdci[9] != 0 );
10620 BITMAP *bmptexture=NULL;
10621 if ( tex_is_bitmap )
10622 {
10623 bmptexture = resolveScriptingBitmap(quad_render_source);
10624 if ( !bmptexture )
10625 {
10626 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Triangle3()");
10627 tex_is_bitmap = 0;
10628 }
10629 }
10630
10631 if ( !tex_is_bitmap )
10632 {
10633 if(tile > 0) // TILE
10634 {
10635 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
10636 }
10637 else // COMBO
10638 {
10639 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
10640 const int32_t tiletodraw = combo_tile(c, 0, 0);
10641 flip = flip ^ c.flip;
10642
10643 if(!(c.animflags & AF_EDITOR_ONLY))
10644 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
10645 }
10646
10647 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
10648 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
10649 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
10650
10651 triangle3d_f(refbmp, polytype, tex, &V1, &V2, &V3);
10652 }
10653 else
10654 {
10655 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
10656 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
10657 if ( !isPowerOfTwo(w) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", w);
10658 if ( !isPowerOfTwo(h) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", h);
10659
10660 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
10661 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
10662 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
10663
10664 triangle3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3);
10665
10666
10667 }
10668 if(mustDestroyBmp)
10669 destroy_bitmap(tex);
10670
10671 }
10672
10673
10674 bool is_layer_transparent(const mapscr& m, int32_t layer)
10675 {
10676 layer = vbound(layer, 0, 5);
10677 return m.layeropacity[layer] == 128;
10678 }
10679
10680 4513893 mapscr *getmapscreen(int32_t map_index, int32_t screen, int32_t layer) //returns NULL for invalid or non-existent layer
10681 {
10682 mapscr *base_scr;
10683 4513893 int32_t index = map_index*MAPSCRS+screen;
10684
10685
2/4
✓ Branch 0 taken 4513893 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4513893 times.
4513893 if((uint32_t)layer > 6 || (uint32_t)index >= TheMaps.size())
10686 return NULL;
10687
10688
2/2
✓ Branch 0 taken 3579197 times.
✓ Branch 1 taken 934696 times.
4513893 if(layer != 0)
10689 {
10690 934696 layer = layer - 1;
10691
10692 934696 base_scr=&(TheMaps[index]);
10693
10694
2/2
✓ Branch 0 taken 842046 times.
✓ Branch 1 taken 92650 times.
934696 if(base_scr->layermap[layer]==0)
10695 92650 return NULL;
10696
10697 842046 index=(base_scr->layermap[layer]-1)*MAPSCRS+base_scr->layerscreen[layer];
10698
10699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 842046 times.
842046 if((uint32_t)index >= TheMaps.size()) // Might as well make sure
10700 return NULL;
10701 842046 }
10702
10703 4421243 return &(TheMaps[index]);
10704 4513893 }
10705
10706 659237800 static bool transparent_combo(int32_t id)
10707 {
10708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 659237800 times.
659237800 if(unsigned(id) >= MAXCOMBOS) return false;
10709 659237800 return bool(combobuf[id].animflags & AF_TRANSPARENT);
10710 659237800 }
10711
10712 199800 void draw_mapscr(BITMAP *b, const mapscr& m, int32_t x, int32_t y, bool transparent)
10713 {
10714
2/2
✓ Branch 0 taken 35164800 times.
✓ Branch 1 taken 199800 times.
35364600 for(int32_t i(0); i < 176; ++i)
10715 {
10716 35164800 const int32_t x2 = ((i&15)<<4) + x;
10717 35164800 const int32_t y2 = (i&0xF0) + y;
10718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35164800 times.
35164800 if(combobuf[m.data[i]].animflags & AF_EDITOR_ONLY) continue;
10719
10720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35164800 times.
35164800 if(transparent != transparent_combo(m.data[i]))
10721 {
10722 overcomboblocktranslucent(b, x2, y2, m.data[i], m.cset[i], 1, 1, 128);
10723 }
10724 else
10725 {
10726 35164800 overcomboblock(b, x2, y2, m.data[i], m.cset[i], 1, 1);
10727 }
10728 35164800 }
10729 199800 }
10730
10731 void draw_map_solidity(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
10732 {
10733 BITMAP* square = create_bitmap_ex(8,16,16);
10734
10735 for(int32_t i(0); i < 176; ++i)
10736 {
10737 const int32_t x2 = ((i&15)<<4) + x;
10738 const int32_t y2 = (i&0xF0) + y;
10739 //Blit the palette index of the solidity value.
10740 clear_to_color(square,(combobuf[m.data[i]].walk&15));
10741 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
10742 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
10743 }
10744 destroy_bitmap(square);
10745 }
10746
10747 void do_bmpdrawscreen_solidmaskr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10748 {
10749 //sdci[1]=layer
10750 //sdci[2]=map
10751 //sdci[3]=screen
10752 //sdci[4]=x
10753 //sdci[5]=y
10754 //sdci[6]=rotation
10755 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
10756
10757 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10758 if ( refbmp == NULL ) return;
10759
10760 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
10761
10762 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10763 int32_t screen = sdci[3]/10000;
10764 int32_t x = sdci[4]/10000;
10765 int32_t y = sdci[5]/10000;
10766 int32_t x1 = x + xoffset;
10767 int32_t y1 = y + yoffset;
10768 int32_t rotation = sdci[6]/10000;
10769 uint32_t index = (uint32_t)map_screen_index(map, screen);
10770
10771 if(index >= TheMaps.size())
10772 {
10773 al_trace("DrawScreen: invalid map or screen index. \n");
10774 return;
10775 }
10776
10777 const mapscr & m = TheMaps[index];
10778
10779
10780 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10781 if ( refbmp == NULL ) return;
10782
10783 if(rotation != 0)
10784 b = script_drawing_commands.AquireSubBitmap(256, 176);
10785
10786 //draw layer 0
10787 draw_map_solidity(b, m, x1, y1);
10788 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS))
10789 {
10790 for(int32_t i(0); i < 6; ++i)
10791 {
10792 if(m.layermap[i] == 0) continue;
10793
10794 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
10795
10796 if(layer_screen_index >= TheMaps.size())
10797 continue;
10798
10799 //draw valid layers
10800 draw_map_solidity(b, TheMaps[ layer_screen_index ], x1, y1);
10801 }
10802 }
10803
10804 if(rotation != 0) // rotate
10805 {
10806 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
10807 script_drawing_commands.ReleaseSubBitmap(b);
10808 }
10809 }
10810
10811 void draw_map_solid(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
10812 {
10813 BITMAP* square = create_bitmap_ex(8,16,16);
10814 BITMAP* subsquare = create_bitmap_ex(8,16,16);
10815 clear_to_color(subsquare,1);
10816
10817 for(int32_t i(0); i < 176; ++i)
10818 {
10819 const int32_t x2 = ((i&15)<<4) + x;
10820 const int32_t y2 = (i&0xF0) + y;
10821 //Blit the palette index of the solidity value.
10822 clear_bitmap(square);
10823 int32_t sol = (combobuf[m.data[i]].walk);
10824 if ( sol & 1 )
10825 {
10826 blit(subsquare, square, 0, 0, 0, 0, 8, 8);
10827 }
10828 if ( sol & 2 )
10829 {
10830 blit(subsquare, square, 0, 0, 0, 8, 8, 8);
10831 }
10832 if ( sol & 4 )
10833 {
10834 blit(subsquare, square, 0, 0, 8, 0, 8, 8);
10835 }
10836 if ( sol &8 ) {
10837 blit(subsquare, square, 0, 0, 8, 8, 8, 8);
10838 }
10839
10840 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
10841 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
10842 }
10843 destroy_bitmap(square);
10844 destroy_bitmap(subsquare);
10845 }
10846
10847 void do_bmpdrawscreen_solidr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10848 {
10849 //sdci[1]=layer
10850 //sdci[2]=map
10851 //sdci[3]=screen
10852 //sdci[4]=x
10853 //sdci[5]=y
10854 //sdci[6]=rotation
10855 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
10856
10857 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10858 if ( refbmp == NULL ) return;
10859
10860 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
10861
10862 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10863 int32_t screen = sdci[3]/10000;
10864 int32_t x = sdci[4]/10000;
10865 int32_t y = sdci[5]/10000;
10866 int32_t x1 = x + xoffset;
10867 int32_t y1 = y + yoffset;
10868 int32_t rotation = sdci[6]/10000;
10869
10870 uint32_t index = (uint32_t)map_screen_index(map, screen);
10871
10872 if(index >= TheMaps.size())
10873 {
10874 al_trace("DrawScreen: invalid map or screen index. \n");
10875 return;
10876 }
10877
10878 const mapscr & m = TheMaps[index];
10879
10880
10881 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10882 if ( refbmp == NULL ) return;
10883
10884 if(rotation != 0)
10885 b = script_drawing_commands.AquireSubBitmap(256, 176);
10886
10887 //draw layer 0
10888 draw_map_solid(b, m, x1, y1);
10889
10890 for(int32_t i(0); i < 6; ++i) //This one doesn't need the QR; it works just fine.
10891 {
10892 if(m.layermap[i] == 0) continue;
10893
10894 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
10895
10896 if(layer_screen_index >= TheMaps.size())
10897 continue;
10898
10899 //draw valid layers
10900 draw_map_solid(b, TheMaps[ layer_screen_index ], x1, y1);
10901 }
10902
10903 if(rotation != 0) // rotate
10904 {
10905 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
10906 script_drawing_commands.ReleaseSubBitmap(b);
10907 }
10908 }
10909
10910 1024 void draw_map_cflag(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
10911 {
10912 1024 BITMAP* square = create_bitmap_ex(8,16,16);
10913
10914
2/2
✓ Branch 0 taken 180224 times.
✓ Branch 1 taken 1024 times.
181248 for(int32_t i(0); i < 176; ++i)
10915 {
10916 180224 const int32_t x2 = ((i&15)<<4) + x;
10917 180224 const int32_t y2 = (i&0xF0) + y;
10918 //Blit the palette index of the solidity value.
10919 180224 clear_to_color(square,m.sflag[i]);
10920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180224 times.
180224 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
10921 180224 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
10922 180224 }
10923 1024 destroy_bitmap(square);
10924 1024 }
10925
10926 1024 void do_bmpdrawscreen_cflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10927 {
10928 //sdci[1]=layer
10929 //sdci[2]=map
10930 //sdci[3]=screen
10931 //sdci[4]=x
10932 //sdci[5]=y
10933 //sdci[6]=rotation
10934 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
10935
10936 1024 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10937
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if ( refbmp == NULL ) return;
10938
10939
2/4
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1024 times.
✗ Branch 3 not taken.
1024 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
10940
10941 1024 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10942 1024 int32_t screen = sdci[3]/10000;
10943 1024 int32_t x = sdci[4]/10000;
10944 1024 int32_t y = sdci[5]/10000;
10945 1024 int32_t x1 = x + xoffset;
10946 1024 int32_t y1 = y + yoffset;
10947 1024 int32_t rotation = sdci[6]/10000;
10948
10949 1024 uint32_t index = (uint32_t)map_screen_index(map, screen);
10950
10951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 if(index >= TheMaps.size())
10952 {
10953 al_trace("DrawScreen: invalid map or screen index. \n");
10954 return;
10955 }
10956
10957 1024 const mapscr & m = TheMaps[index];
10958
10959
10960 1024 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10961
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if ( refbmp == NULL ) return;
10962
10963
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(rotation != 0)
10964 b = script_drawing_commands.AquireSubBitmap(256, 176);
10965
10966 //draw layer 0
10967 1024 draw_map_cflag(b, m, x1, y1);
10968
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS))
10969 {
10970 for(int32_t i(0); i < 6; ++i)
10971 {
10972 if(m.layermap[i] == 0) continue;
10973
10974 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
10975
10976 if(layer_screen_index >= TheMaps.size())
10977 continue;
10978
10979 //draw valid layers
10980 draw_map_cflag(b, TheMaps[ layer_screen_index ], x1, y1);
10981 }
10982 }
10983
10984
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(rotation != 0) // rotate
10985 {
10986 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
10987 script_drawing_commands.ReleaseSubBitmap(b);
10988 }
10989 1024 }
10990
10991
10992 void draw_map_combotype(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
10993 {
10994 BITMAP* square = create_bitmap_ex(8,16,16);
10995
10996 for(int32_t i(0); i < 176; ++i)
10997 {
10998 const int32_t x2 = ((i&15)<<4) + x;
10999 const int32_t y2 = (i&0xF0) + y;
11000 //Blit the palette index of the solidity value.
11001 clear_to_color(square,(combobuf[m.data[i]].type));
11002 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
11003 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
11004 }
11005 destroy_bitmap(square);
11006 }
11007
11008 void do_bmpdrawscreen_ctyper(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11009 {
11010 //sdci[1]=layer
11011 //sdci[2]=map
11012 //sdci[3]=screen
11013 //sdci[4]=x
11014 //sdci[5]=y
11015 //sdci[6]=rotation
11016 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
11017
11018 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11019 if ( refbmp == NULL ) return;
11020
11021 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
11022
11023 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11024 int32_t screen = sdci[3]/10000;
11025 int32_t x = sdci[4]/10000;
11026 int32_t y = sdci[5]/10000;
11027 int32_t x1 = x + xoffset;
11028 int32_t y1 = y + yoffset;
11029 int32_t rotation = sdci[6]/10000;
11030
11031 uint32_t index = (uint32_t)map_screen_index(map, screen);
11032
11033 if(index >= TheMaps.size())
11034 {
11035 al_trace("DrawScreen: invalid map or screen index. \n");
11036 return;
11037 }
11038
11039 const mapscr & m = TheMaps[index];
11040
11041
11042 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11043 if ( refbmp == NULL ) return;
11044
11045 if(rotation != 0)
11046 b = script_drawing_commands.AquireSubBitmap(256, 176);
11047
11048 //draw layer 0
11049 draw_map_combotype(b, m, x1, y1);
11050
11051 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS))
11052 {
11053 for(int32_t i(0); i < 6; ++i)
11054 {
11055 if(m.layermap[i] == 0) continue;
11056
11057 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
11058
11059 if(layer_screen_index >= TheMaps.size())
11060 continue;
11061
11062 //draw valid layers
11063 draw_map_combotype(b, TheMaps[ layer_screen_index ], x1, y1);
11064 }
11065 }
11066
11067 if(rotation != 0) // rotate
11068 {
11069 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
11070 script_drawing_commands.ReleaseSubBitmap(b);
11071 }
11072 }
11073
11074
11075 void draw_map_comboiflag(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
11076 {
11077 BITMAP* square = create_bitmap_ex(8,16,16);
11078
11079 for(int32_t i(0); i < 176; ++i)
11080 {
11081 const int32_t x2 = ((i&15)<<4) + x;
11082 const int32_t y2 = (i&0xF0) + y;
11083 //Blit the palette index of the solidity value.
11084 clear_to_color(square,(combobuf[m.data[i]].flag));
11085 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
11086 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
11087 }
11088 destroy_bitmap(square);
11089 }
11090
11091 void do_bmpdrawscreen_ciflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11092 {
11093 //sdci[1]=layer
11094 //sdci[2]=map
11095 //sdci[3]=screen
11096 //sdci[4]=x
11097 //sdci[5]=y
11098 //sdci[6]=rotation
11099 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
11100
11101 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11102 if ( refbmp == NULL ) return;
11103
11104 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
11105
11106 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11107 int32_t screen = sdci[3]/10000;
11108 int32_t x = sdci[4]/10000;
11109 int32_t y = sdci[5]/10000;
11110 int32_t x1 = x + xoffset;
11111 int32_t y1 = y + yoffset;
11112 int32_t rotation = sdci[6]/10000;
11113
11114 uint32_t index = (uint32_t)map_screen_index(map, screen);
11115
11116 if(index >= TheMaps.size())
11117 {
11118 al_trace("DrawScreen: invalid map or screen index. \n");
11119 return;
11120 }
11121
11122 const mapscr & m = TheMaps[index];
11123
11124
11125 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11126 if ( refbmp == NULL ) return;
11127
11128 if(rotation != 0)
11129 b = script_drawing_commands.AquireSubBitmap(256, 176);
11130
11131 //draw layer 0
11132 draw_map_comboiflag(b, m, x1, y1);
11133
11134 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS))
11135 {
11136 for(int32_t i(0); i < 6; ++i)
11137 {
11138 if(m.layermap[i] == 0) continue;
11139
11140 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
11141
11142 if(layer_screen_index >= TheMaps.size())
11143 continue;
11144
11145 //draw valid layers
11146 draw_map_comboiflag(b, TheMaps[ layer_screen_index ], x1, y1);
11147 }
11148 }
11149
11150 if(rotation != 0) // rotate
11151 {
11152 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
11153 script_drawing_commands.ReleaseSubBitmap(b);
11154 }
11155 }
11156
11157 4370235 void do_drawlayerr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11158 {
11159 //sdci[1]=layer
11160 //sdci[2]=map
11161 //sdci[3]=screen
11162 //sdci[4]=layer
11163 //sdci[5]=x
11164 //sdci[6]=y
11165 //sdci[7]=rotation
11166 //sdci[8]=opacity
11167
11168 4370235 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11169 4370235 int32_t screen = sdci[3]/10000;
11170 4370235 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11171 4370235 int32_t x = sdci[5]/10000;
11172 4370235 int32_t y = sdci[6]/10000;
11173 4370235 int32_t x1 = x + xoffset;
11174 4370235 int32_t y1 = y + yoffset;
11175 4370235 int32_t rotation = sdci[7]/10000;
11176 4370235 int32_t opacity = sdci[8]/10000;
11177
11178 4370235 uint32_t index = (uint32_t)map_screen_index(map, screen);
11179 4370235 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11180
11181
2/2
✓ Branch 0 taken 4318301 times.
✓ Branch 1 taken 51934 times.
4370235 if(!m) //no need to log it.
11182 51934 return;
11183
11184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4318301 times.
4318301 if(index >= TheMaps.size())
11185 {
11186 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11187 return;
11188 }
11189
11190 4318301 const mapscr & l = *m;
11191
11192 4318301 BITMAP* b = bmp;
11193
11194
1/2
✓ Branch 0 taken 4318301 times.
✗ Branch 1 not taken.
4318301 if(rotation != 0)
11195 b = script_drawing_commands.AquireSubBitmap(256, 176);
11196
11197
11198 4318301 const int32_t maxX = isOffScreen ? 512 : 256;
11199
2/2
✓ Branch 0 taken 4298918 times.
✓ Branch 1 taken 19383 times.
4318301 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11200 4318301 bool transparent = opacity <= 128;
11201
11202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4318301 times.
4318301 if(rotation != 0) // rotate
11203 {
11204 draw_mapscr(b, l, x1, y1, transparent);
11205
11206 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11207 script_drawing_commands.ReleaseSubBitmap(b);
11208 }
11209 else
11210 {
11211
2/2
✓ Branch 0 taken 760020976 times.
✓ Branch 1 taken 4318301 times.
764339277 for(int32_t i(0); i < 176; ++i)
11212 {
11213 760020976 const int32_t x2 = ((i&15)<<4) + x1;
11214 760020976 const int32_t y2 = (i&0xF0) + y1;
11215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760020976 times.
760020976 if(combobuf[l.data[i]].animflags & AF_EDITOR_ONLY) continue;
11216
11217
7/8
✓ Branch 0 taken 669516342 times.
✓ Branch 1 taken 90504634 times.
✓ Branch 2 taken 669516342 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 615110950 times.
✓ Branch 5 taken 54405392 times.
✓ Branch 6 taken 9155742 times.
✓ Branch 7 taken 605955208 times.
760020976 if(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY) //in clipping rect
11218 {
11219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 605955208 times.
605955208 if(opacity < 128 != transparent_combo(l.data[i]))
11220 {
11221 overcomboblocktranslucent(b, x2, y2, l.data[i], l.cset[i], 1, 1, 128);
11222 }
11223 else
11224 {
11225 605955208 overcomboblock(b, x2, y2, l.data[i], l.cset[i], 1, 1);
11226 }
11227 605955208 }
11228 760020976 }
11229 }
11230
11231 //putscr
11232 4370235 }
11233
11234
11235
11236 50406 void do_drawscreenr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11237 {
11238 //sdci[1]=layer
11239 //sdci[2]=map
11240 //sdci[3]=screen
11241 //sdci[4]=x
11242 //sdci[5]=y
11243 //sdci[6]=rotation
11244
11245 50406 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11246 50406 int32_t screen = sdci[3]/10000;
11247 50406 int32_t x = sdci[4]/10000;
11248 50406 int32_t y = sdci[5]/10000;
11249 50406 int32_t x1 = x + xoffset;
11250 50406 int32_t y1 = y + yoffset;
11251 50406 int32_t rotation = sdci[6]/10000;
11252
11253 50406 uint32_t index = (uint32_t)map_screen_index(map, screen);
11254
11255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50406 times.
50406 if(index >= TheMaps.size())
11256 {
11257 al_trace("DrawScreen: invalid map or screen index. \n");
11258 return;
11259 }
11260
11261 50406 const mapscr & m = TheMaps[index];
11262
11263
11264 50406 BITMAP* b = bmp;
11265
11266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50406 times.
50406 if(rotation != 0)
11267 b = script_drawing_commands.AquireSubBitmap(256, 176);
11268
11269 //draw layer 0
11270 50406 draw_mapscr(b, m, x1, y1, false);
11271
11272
2/2
✓ Branch 0 taken 50406 times.
✓ Branch 1 taken 302436 times.
352842 for(int32_t i(0); i < 6; ++i)
11273 {
11274
2/2
✓ Branch 0 taken 137944 times.
✓ Branch 1 taken 164492 times.
302436 if(m.layermap[i] == 0) continue;
11275
11276 137944 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
11277
11278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137944 times.
137944 if(layer_screen_index >= TheMaps.size())
11279 continue;
11280
11281 137944 bool trans = m.layeropacity[i] == 128;
11282
11283 //draw valid layers
11284 137944 draw_mapscr(b, TheMaps[ layer_screen_index ], x1, y1, trans);
11285 137944 }
11286
11287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50406 times.
50406 if(rotation != 0) // rotate
11288 {
11289 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11290 script_drawing_commands.ReleaseSubBitmap(b);
11291 }
11292 50406 }
11293
11294
11295 143658 void do_bmpdrawlayerr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11296 {
11297 //sdci[1]=layer
11298 //sdci[2]=map
11299 //sdci[3]=screen
11300 //sdci[4]=layer
11301 //sdci[5]=x
11302 //sdci[6]=y
11303 //sdci[7]=rotation
11304 //[8] noclip
11305 //sdci[9]=opacity
11306 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
11307
11308 143658 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11309
1/2
✓ Branch 0 taken 143658 times.
✗ Branch 1 not taken.
143658 if ( refbmp == NULL ) return;
11310
11311 143658 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11312 143658 int32_t screen = sdci[3]/10000;
11313 143658 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11314 143658 int32_t x = sdci[5]/10000;
11315 143658 int32_t y = sdci[6]/10000;
11316 143658 int32_t rotation = sdci[7]/10000;
11317
11318 143658 byte noclip = 0;//(sdci[8]!=0);
11319 143658 int32_t opacity = sdci[8]/10000;
11320 143658 uint32_t index = (uint32_t)map_screen_index(map, screen);
11321 143658 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11322
11323
2/2
✓ Branch 0 taken 102942 times.
✓ Branch 1 taken 40716 times.
143658 if(!m) //no need to log it.
11324 40716 return;
11325
11326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102942 times.
102942 if(index >= TheMaps.size())
11327 {
11328 Z_scripterrlog("DrawLayer: invalid map index \"%i\". Map count is %zu.\n", index, TheMaps.size());
11329 return;
11330 }
11331
11332 102942 const mapscr & l = *m;
11333
11334 102942 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11335
1/2
✓ Branch 0 taken 102942 times.
✗ Branch 1 not taken.
102942 if ( refbmp == NULL ) return;
11336
2/4
✓ Branch 0 taken 102942 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102942 times.
✗ Branch 3 not taken.
102942 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
11337
1/2
✓ Branch 0 taken 102942 times.
✗ Branch 1 not taken.
102942 if(rotation != 0)
11338 b = script_drawing_commands.AquireSubBitmap(256, 176);
11339
11340
11341 102942 const int32_t maxX = isOffScreen ? 512 : 256;
11342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102942 times.
102942 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11343 102942 bool transparent = opacity <= 128;
11344
11345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102942 times.
102942 if(rotation != 0) // rotate
11346 {
11347 draw_mapscr(b, l, x, y, transparent);
11348
11349 rotate_sprite(refbmp, b, x, y, degrees_to_fixed(rotation));
11350 script_drawing_commands.ReleaseSubBitmap(b);
11351 }
11352 else
11353 {
11354
2/2
✓ Branch 0 taken 18117792 times.
✓ Branch 1 taken 102942 times.
18220734 for(int32_t i(0); i < 176; ++i)
11355 {
11356 18117792 const int32_t x2 = ((i&15)<<4) + x;
11357 18117792 const int32_t y2 = (i&0xF0) + y;
11358
11359 //if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11360 {
11361 18117792 auto& c = GET_DRAWING_COMBO(l.data[i]);
11362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18117792 times.
18117792 if(c.animflags & AF_EDITOR_ONLY) continue;
11363 18117792 const int32_t tile = combo_tile(c, x2, y2);
11364
11365
2/2
✓ Branch 0 taken 37572 times.
✓ Branch 1 taken 18080220 times.
18117792 if(opacity < 128 != transparent_combo(l.data[i]))
11366 37572 overtiletranslucent16(refbmp, tile, x2, y2, l.cset[i], c.flip, opacity);
11367 else
11368 18080220 overtile16(refbmp, tile, x2, y2, l.cset[i], c.flip);
11369
11370 //putcombo( b, xx, yy, l.data[i], l.cset[i] );
11371 }
11372 18117792 }
11373 }
11374
11375 //putscr
11376 143658 }
11377
11378
11379
11380 2740 void do_bmpdrawscreenr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11381 {
11382 //sdci[1]=layer
11383 //sdci[2]=map
11384 //sdci[3]=screen
11385 //sdci[4]=x
11386 //sdci[5]=y
11387 //sdci[6]=rotation
11388 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
11389
11390 2740 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11391
1/2
✓ Branch 0 taken 2740 times.
✗ Branch 1 not taken.
2740 if ( refbmp == NULL ) return;
11392
11393
2/4
✓ Branch 0 taken 2740 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2740 times.
2740 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
11394
11395 2740 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11396 2740 int32_t screen = sdci[3]/10000;
11397 2740 int32_t x = sdci[4]/10000;
11398 2740 int32_t y = sdci[5]/10000;
11399 2740 int32_t x1 = x + xoffset;
11400 2740 int32_t y1 = y + yoffset;
11401 2740 int32_t rotation = sdci[6]/10000;
11402
11403 2740 uint32_t index = (uint32_t)map_screen_index(map, screen);
11404
11405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2740 times.
2740 if(index >= TheMaps.size())
11406 {
11407 al_trace("DrawScreen: invalid map or screen index. \n");
11408 return;
11409 }
11410
11411 2740 const mapscr & m = TheMaps[index];
11412
11413
11414 2740 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2740 times.
2740 if ( refbmp == NULL ) return;
11416
11417
1/2
✓ Branch 0 taken 2740 times.
✗ Branch 1 not taken.
2740 if(rotation != 0)
11418 b = script_drawing_commands.AquireSubBitmap(256, 176);
11419
11420 //draw layer 0
11421 2740 draw_mapscr(b, m, x1, y1, false);
11422
11423
2/2
✓ Branch 0 taken 2740 times.
✓ Branch 1 taken 16440 times.
19180 for(int32_t i(0); i < 6; ++i)
11424 {
11425
2/2
✓ Branch 0 taken 8710 times.
✓ Branch 1 taken 7730 times.
16440 if(m.layermap[i] == 0) continue;
11426
11427 8710 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
11428
11429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8710 times.
8710 if(layer_screen_index >= TheMaps.size())
11430 continue;
11431
11432 8710 bool trans = m.layeropacity[i] == 128;
11433
11434 //draw valid layers
11435 8710 draw_mapscr(b, TheMaps[ layer_screen_index ], x1, y1, trans);
11436 8710 }
11437
11438
1/2
✓ Branch 0 taken 2740 times.
✗ Branch 1 not taken.
2740 if(rotation != 0) // rotate
11439 {
11440 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
11441 script_drawing_commands.ReleaseSubBitmap(b);
11442 }
11443 2740 }
11444
11445 void do_bmpdrawlayersolidmaskr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11446 {
11447 //sdci[1]=layer
11448 //sdci[2]=map
11449 //sdci[3]=screen
11450 //sdci[4]=layer
11451 //sdci[5]=x
11452 //sdci[6]=y
11453 //sdci[7]=rotation
11454 //sdci[8]=bool noclip
11455 //sdci[9] == opacity
11456
11457 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11458 int32_t screen = sdci[3]/10000;
11459 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11460 int32_t x = sdci[5]/10000;
11461 int32_t y = sdci[6]/10000;
11462 int32_t x1 = x + xoffset;
11463 int32_t y1 = y + yoffset;
11464 int32_t rotation = sdci[7]/10000;
11465 byte noclip = (sdci[8]!=0);
11466 int32_t opacity = sdci[9]/10000;
11467
11468 uint32_t index = (uint32_t)map_screen_index(map, screen);
11469 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11470
11471 if(!m) //no need to log it.
11472 return;
11473
11474 if(index >= TheMaps.size())
11475 {
11476 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11477 return;
11478 }
11479
11480 const mapscr & l = *m;
11481
11482 BITMAP* b = bmp;
11483
11484 if(rotation != 0)
11485 b = script_drawing_commands.AquireSubBitmap(256, 176);
11486
11487
11488 const int32_t maxX = isOffScreen ? 512 : 256;
11489 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11490 bool transparent = opacity <= 128;
11491
11492 if(rotation != 0) // rotate
11493 {
11494 draw_map_solid(b, l, x1, y1);
11495
11496 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11497 script_drawing_commands.ReleaseSubBitmap(b);
11498 }
11499 else
11500 {
11501 BITMAP* square = create_bitmap_ex(8,16,16);
11502 BITMAP* subsquare = create_bitmap_ex(8,16,16);
11503 clear_to_color(subsquare,1);
11504 for(int32_t i(0); i < 176; ++i)
11505 {
11506 const int32_t x2 = ((i&15)<<4) + x1;
11507 const int32_t y2 = (i&0xF0) + y1;
11508
11509 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11510 {
11511 int32_t sol = (combobuf[l.data[i]].walk);
11512
11513 if ( sol & 1 )
11514 {
11515 blit(subsquare, square, 0, 0, 0, 0, 8, 8);
11516 }
11517 if ( sol & 2 )
11518 {
11519 blit(subsquare, square, 0, 0, 0, 8, 8, 8);
11520 }
11521 if ( sol & 4 )
11522 {
11523 blit(subsquare, square, 0, 0, 8, 0, 8, 8);
11524 }
11525 if ( sol &8 ) {
11526 blit(subsquare, square, 0, 0, 8, 8, 8, 8);
11527 }
11528
11529 blit(square, b, 0, 0, x2, y2, square->w, square->h);
11530 }
11531 }
11532 destroy_bitmap(square);
11533 destroy_bitmap(subsquare);
11534 }
11535
11536 //putscr
11537 }
11538
11539 void do_bmpdrawlayersolidityr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11540 {
11541 //sdci[1]=layer
11542 //sdci[2]=map
11543 //sdci[3]=screen
11544 //sdci[4]=layer
11545 //sdci[5]=x
11546 //sdci[6]=y
11547 //sdci[7]=rotation
11548 //[8] noclip
11549 //sdci[9]=opacity
11550
11551
11552 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11553 int32_t screen = sdci[3]/10000;
11554 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11555 int32_t x = sdci[5]/10000;
11556 int32_t y = sdci[6]/10000;
11557 int32_t x1 = x + xoffset;
11558 int32_t y1 = y + yoffset;
11559 int32_t rotation = sdci[7]/10000;
11560 byte noclip = (sdci[8]!=0);
11561 int32_t opacity = sdci[9]/10000;
11562
11563 uint32_t index = (uint32_t)map_screen_index(map, screen);
11564 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11565
11566 if(!m) //no need to log it.
11567 return;
11568
11569 if(index >= TheMaps.size())
11570 {
11571 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11572 return;
11573 }
11574
11575 const mapscr & l = *m;
11576
11577 BITMAP* b = bmp;
11578
11579 if(rotation != 0)
11580 b = script_drawing_commands.AquireSubBitmap(256, 176);
11581
11582
11583 const int32_t maxX = isOffScreen ? 512 : 256;
11584 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11585 bool transparent = opacity <= 128;
11586
11587 if(rotation != 0) // rotate
11588 {
11589 draw_map_solidity(b, l, x1, y1);
11590
11591 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11592 script_drawing_commands.ReleaseSubBitmap(b);
11593 }
11594 else
11595 {
11596 BITMAP* square = create_bitmap_ex(8,16,16);
11597 for(int32_t i(0); i < 176; ++i)
11598 {
11599 const int32_t x2 = ((i&15)<<4) + x1;
11600 const int32_t y2 = (i&0xF0) + y1;
11601
11602 if(noclip && (x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11603 {
11604 clear_to_color(square,(combobuf[l.data[i]].walk&15));
11605 blit(square, b, 0, 0, x2, y2, square->w, square->h);
11606 }
11607 }
11608 destroy_bitmap(square);
11609 }
11610
11611 //putscr
11612 }
11613
11614 void do_bmpdrawlayercflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11615 {
11616 //sdci[1]=layer
11617 //sdci[2]=map
11618 //sdci[3]=screen
11619 //sdci[4]=layer
11620 //sdci[5]=x
11621 //sdci[6]=y
11622 //sdci[7]=rotation
11623 //[8] noclip
11624 //sdci[9]=opacity
11625
11626
11627 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11628 int32_t screen = sdci[3]/10000;
11629 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11630 int32_t x = sdci[5]/10000;
11631 int32_t y = sdci[6]/10000;
11632 int32_t x1 = x + xoffset;
11633 int32_t y1 = y + yoffset;
11634 int32_t rotation = sdci[7]/10000;
11635
11636 byte noclip = (sdci[8]!=0);
11637 int32_t opacity = sdci[9]/10000;
11638
11639 uint32_t index = (uint32_t)map_screen_index(map, screen);
11640 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11641
11642 if(!m) //no need to log it.
11643 return;
11644
11645 if(index >= TheMaps.size())
11646 {
11647 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11648 return;
11649 }
11650
11651 const mapscr & l = *m;
11652
11653 BITMAP* b = bmp;
11654
11655 if(rotation != 0)
11656 b = script_drawing_commands.AquireSubBitmap(256, 176);
11657
11658
11659 const int32_t maxX = isOffScreen ? 512 : 256;
11660 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11661 bool transparent = opacity <= 128;
11662
11663 if(rotation != 0) // rotate
11664 {
11665 draw_map_cflag(b, l, x1, y1);
11666
11667 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11668 script_drawing_commands.ReleaseSubBitmap(b);
11669 }
11670 else
11671 {
11672 BITMAP* square = create_bitmap_ex(8,16,16);
11673 for(int32_t i(0); i < 176; ++i)
11674 {
11675 const int32_t x2 = ((i&15)<<4) + x1;
11676 const int32_t y2 = (i&0xF0) + y1;
11677
11678 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11679 {
11680 clear_to_color(square,l.sflag[i]);
11681 blit(square, b, 0, 0, x2, y2, square->w, square->h);
11682 }
11683 }
11684 destroy_bitmap(square);
11685 }
11686
11687 //putscr
11688 }
11689
11690 void do_bmpdrawlayerctyper(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11691 {
11692 //sdci[1]=layer
11693 //sdci[2]=map
11694 //sdci[3]=screen
11695 //sdci[4]=layer
11696 //sdci[5]=x
11697 //sdci[6]=y
11698 //sdci[7]=rotation
11699 //[8] noclip
11700 //sdci[9]=opacity
11701
11702 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11703 int32_t screen = sdci[3]/10000;
11704 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11705 int32_t x = sdci[5]/10000;
11706 int32_t y = sdci[6]/10000;
11707 int32_t x1 = x + xoffset;
11708 int32_t y1 = y + yoffset;
11709 int32_t rotation = sdci[7]/10000;
11710
11711 byte noclip = (sdci[8]!=0);
11712 int32_t opacity = sdci[9]/10000;
11713 uint32_t index = (uint32_t)map_screen_index(map, screen);
11714 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11715
11716 if(!m) //no need to log it.
11717 return;
11718
11719 if(index >= TheMaps.size())
11720 {
11721 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11722 return;
11723 }
11724
11725 const mapscr & l = *m;
11726
11727 BITMAP* b = bmp;
11728
11729 if(rotation != 0)
11730 b = script_drawing_commands.AquireSubBitmap(256, 176);
11731
11732
11733 const int32_t maxX = isOffScreen ? 512 : 256;
11734 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11735 bool transparent = opacity <= 128;
11736
11737 if(rotation != 0) // rotate
11738 {
11739 draw_map_combotype(b, l, x1, y1);
11740
11741 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11742 script_drawing_commands.ReleaseSubBitmap(b);
11743 }
11744 else
11745 {
11746 BITMAP* square = create_bitmap_ex(8,16,16);
11747 for(int32_t i(0); i < 176; ++i)
11748 {
11749 const int32_t x2 = ((i&15)<<4) + x1;
11750 const int32_t y2 = (i&0xF0) + y1;
11751
11752 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11753 {
11754 clear_to_color(square,(combobuf[l.data[i]].type));
11755 blit(square, b, 0, 0, x2, y2, square->w, square->h);
11756 }
11757 }
11758 destroy_bitmap(square);
11759 }
11760
11761 //putscr
11762 }
11763
11764 void do_bmpdrawlayerciflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11765 {
11766 //sdci[1]=layer
11767 //sdci[2]=map
11768 //sdci[3]=screen
11769 //sdci[4]=layer
11770 //sdci[5]=x
11771 //sdci[6]=y
11772 //sdci[7]=rotation
11773 //[8] noclip
11774 //sdci[9]=opacity
11775
11776 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11777 int32_t screen = sdci[3]/10000;
11778 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11779 int32_t x = sdci[5]/10000;
11780 int32_t y = sdci[6]/10000;
11781 int32_t x1 = x + xoffset;
11782 int32_t y1 = y + yoffset;
11783 int32_t rotation = sdci[7]/10000;
11784 byte noclip = (sdci[8]!=0);
11785 int32_t opacity = sdci[9]/10000;
11786
11787 uint32_t index = (uint32_t)map_screen_index(map, screen);
11788 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11789
11790 if(!m) //no need to log it.
11791 return;
11792
11793 if(index >= TheMaps.size())
11794 {
11795 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11796 return;
11797 }
11798
11799 const mapscr & l = *m;
11800
11801 BITMAP* b = bmp;
11802
11803 if(rotation != 0)
11804 b = script_drawing_commands.AquireSubBitmap(256, 176);
11805
11806
11807 const int32_t maxX = isOffScreen ? 512 : 256;
11808 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11809 bool transparent = opacity <= 128;
11810
11811 if(rotation != 0) // rotate
11812 {
11813 draw_map_comboiflag(b, l, x1, y1);
11814
11815 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11816 script_drawing_commands.ReleaseSubBitmap(b);
11817 }
11818 else
11819 {
11820 BITMAP* square = create_bitmap_ex(8,16,16);
11821 for(int32_t i(0); i < 176; ++i)
11822 {
11823 const int32_t x2 = ((i&15)<<4) + x1;
11824 const int32_t y2 = (i&0xF0) + y1;
11825
11826 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11827 {
11828 clear_to_color(square,(combobuf[l.data[i]].flag));
11829 blit(square, b, 0, 0, x2, y2, square->w, square->h);
11830 }
11831 }
11832 destroy_bitmap(square);
11833 }
11834
11835 //putscr
11836 }
11837
11838
11839
11840 /////////////////////////////////////////////////////////
11841 // do primitives
11842 ////////////////////////////////////////////////////////
11843
11844 // Draw commands can vary in terms of the origin/coordinate system to draw as. This
11845 // is controlled via `DrawOrigin`. Previous to `DrawOrigin`, this always drew
11846 // relative to the playing field (except for offscreen bitmaps).
11847 417511489 void do_primitives(BITMAP *targetBitmap, int32_t type)
11848 {
11849 417511489 do_primitives(targetBitmap, type, 0, playing_field_offset);
11850 417511489 }
11851
11852 418874937 void do_primitives(BITMAP *targetBitmap, int32_t type, int32_t xoff, int32_t yoff)
11853 {
11854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 418874937 times.
418874937 if(type > 7)
11855 return;
11856
3/4
✓ Branch 0 taken 133756568 times.
✓ Branch 1 taken 285118369 times.
✓ Branch 2 taken 133756568 times.
✗ Branch 3 not taken.
418874937 if(type >= 0 && origin_scr->hidescriptlayers & (1<<type))
11857 return; //Script draws hidden for this layer
11858
2/2
✓ Branch 0 taken 4856981 times.
✓ Branch 1 taken 414017956 times.
418874937 if(!script_drawing_commands.is_dirty(type))
11859 414017956 return; //No draws to this layer
11860
11861 4856981 color_map = trans_table2;
11862 //--script_drawing_commands[][] reference--
11863 //[][0]: type
11864 //[][1-16]: defined by type
11865 //...
11866 //[][DRAWCMD_BMP_TARGET]: bitmap pointer
11867 //[][DRAWCMD_CURRENT_TARGET]: current render target at time command is queued? unused?
11868
11869 4856981 const int32_t type_mul_10000 = type * 10000;
11870 4856981 const int32_t numDrawCommandsToProcess = script_drawing_commands.Count();
11871 4856981 FFCore.numscriptdraws = numDrawCommandsToProcess;
11872
11873
2/2
✓ Branch 0 taken 369787697 times.
✓ Branch 1 taken 4856981 times.
374644678 for (int i = 0; i < numDrawCommandsToProcess; i++)
11874 {
11875 369787697 auto& command = script_drawing_commands[i];
11876 369787697 int32_t *sdci = &script_drawing_commands[i][0];
11877
11878
2/2
✓ Branch 0 taken 246614455 times.
✓ Branch 1 taken 123173242 times.
369787697 if (sdci[1] != type_mul_10000)
11879 246614455 continue;
11880
11881 123173242 DrawOrigin draw_origin = command.draw_origin;
11882
11883 // get the correct render target, if set via Screen->SetRenderTarget
11884 // Note: This is a deprecated feature.
11885 123173242 BITMAP *bmp = zscriptDrawingRenderTarget->GetTargetBitmap(sdci[DRAWCMD_CURRENT_TARGET]);
11886 bool isTargetOffScreenBmp;
11887
11888
2/2
✓ Branch 0 taken 6478283 times.
✓ Branch 1 taken 116694959 times.
123173242 if(!bmp)
11889 {
11890 116694959 bmp = targetBitmap;
11891 116694959 isTargetOffScreenBmp = false;
11892 116694959 }
11893 else
11894 {
11895 // Render target was set to a internal bitmap (but not the screen bitmap).
11896 6478283 isTargetOffScreenBmp = true;
11897 6478283 draw_origin = DrawOrigin::Screen;
11898 }
11899
11900 123173242 current_target_bmp = bmp;
11901
11902 int xoffset, yoffset;
11903
1/2
✓ Branch 0 taken 123173242 times.
✗ Branch 1 not taken.
123173242 if (auto r = get_draw_origin_offset(draw_origin, command.draw_origin_target, xoff, yoff))
11904 {
11905 123173242 std::tie(xoffset, yoffset) = *r;
11906 123173242 }
11907 else
11908 {
11909 continue;
11910 }
11911
11912 123173242 secondary_draw_origin_xoff = 0;
11913 123173242 secondary_draw_origin_yoff = 0;
11914
2/2
✓ Branch 0 taken 121378016 times.
✓ Branch 1 taken 1795226 times.
123173242 if (command.secondary_draw_origin != DrawOrigin::Default)
11915 {
11916
1/2
✓ Branch 0 taken 1795226 times.
✗ Branch 1 not taken.
1795226 if (auto r = get_draw_origin_offset(command.secondary_draw_origin, command.secondary_draw_origin_target, xoff, yoff))
11917 {
11918 1795226 std::tie(secondary_draw_origin_xoff, secondary_draw_origin_yoff) = *r;
11919 1795226 }
11920 else
11921 {
11922 continue;
11923 }
11924 1795226 }
11925
11926
40/87
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3344855 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1170681 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1850 times.
✓ Branch 7 taken 2351475 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 404879 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 2302534 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 2761920 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 5327982 times.
✓ Branch 19 taken 30256034 times.
✓ Branch 20 taken 964155 times.
✓ Branch 21 taken 176452 times.
✓ Branch 22 taken 1607511 times.
✓ Branch 23 taken 201739 times.
✓ Branch 24 taken 9266 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 1080 times.
✓ Branch 29 taken 937483 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 4370235 times.
✓ Branch 32 taken 50406 times.
✓ Branch 33 taken 12431 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 192290 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 502 times.
✓ Branch 38 taken 144 times.
✗ Branch 39 not taken.
✓ Branch 40 taken 80910 times.
✓ Branch 41 taken 64994 times.
✗ Branch 42 not taken.
✓ Branch 43 taken 11288 times.
✗ Branch 44 not taken.
✓ Branch 45 taken 1982263 times.
✓ Branch 46 taken 40175665 times.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✓ Branch 49 taken 865 times.
✓ Branch 50 taken 45504 times.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✓ Branch 56 taken 143658 times.
✓ Branch 57 taken 2740 times.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✓ Branch 60 taken 1024 times.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✓ Branch 63 taken 2062708 times.
✗ Branch 64 not taken.
✓ Branch 65 taken 113653 times.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✓ Branch 72 taken 2134433 times.
✓ Branch 73 taken 34749 times.
✓ Branch 74 taken 43007 times.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✓ Branch 80 taken 19821648 times.
✗ Branch 81 not taken.
✓ Branch 82 taken 7323 times.
✗ Branch 83 not taken.
✓ Branch 84 taken 906 times.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
123173242 switch(sdci[0])
11927 {
11928 case RECTR:
11929 {
11930 3344855 do_rectr(bmp, sdci, xoffset, yoffset);
11931 }
11932 3344855 break;
11933 case FRAMER:
11934 {
11935 do_framer(bmp, sdci, xoffset, yoffset);
11936 }
11937 break;
11938
11939
11940 case CIRCLER:
11941 {
11942 1170681 do_circler(bmp, sdci, xoffset, yoffset);
11943 }
11944 1170681 break;
11945
11946 case ARCR:
11947 {
11948 do_arcr(bmp, sdci, xoffset, yoffset);
11949 }
11950 break;
11951
11952 case ELLIPSER:
11953 {
11954 1850 do_ellipser(bmp, sdci, xoffset, yoffset);
11955 }
11956 1850 break;
11957
11958 case LINER:
11959 {
11960 2351475 do_liner(bmp, sdci, xoffset, yoffset);
11961 }
11962 2351475 break;
11963
11964 case SPLINER:
11965 {
11966 do_spliner(bmp, sdci, xoffset, yoffset);
11967 }
11968 break;
11969
11970 case PUTPIXELR:
11971 {
11972 404879 do_putpixelr(bmp, sdci, xoffset, yoffset);
11973 }
11974 404879 break;
11975 case PIXELARRAYR:
11976 {
11977 do_putpixelsr(bmp, i, sdci, xoffset, yoffset);
11978 }
11979 break;
11980
11981 case TILEARRAYR:
11982 {
11983 do_fasttilesr(bmp, i, sdci, xoffset, yoffset);
11984 }
11985 break;
11986
11987 case LINESARRAY:
11988 {
11989 do_linesr(bmp, i, sdci, xoffset, yoffset);
11990 }
11991 break;
11992
11993 case COMBOARRAYR:
11994 {
11995 do_fastcombosr(bmp, i, sdci, xoffset, yoffset);
11996 }
11997 break;
11998
11999
12000
12001 case DRAWTILER:
12002 {
12003 2302534 do_drawtiler(bmp, sdci, xoffset, yoffset);
12004 }
12005 2302534 break;
12006
12007 case DRAWTILECLOAKEDR:
12008 {
12009 do_drawtilecloakedr(bmp, sdci, xoffset, yoffset);
12010 }
12011 break;
12012
12013 case DRAWCOMBOR:
12014 {
12015 2761920 do_drawcombor(bmp, sdci, xoffset, yoffset);
12016 }
12017 2761920 break;
12018
12019 case DRAWCOMBOCLOAKEDR:
12020 {
12021 do_drawcombocloakedr(bmp, sdci, xoffset, yoffset);
12022 }
12023 break;
12024
12025 case FASTTILER:
12026 {
12027 5327982 do_fasttiler(bmp, sdci, xoffset, yoffset);
12028 }
12029 5327982 break;
12030
12031 case FASTCOMBOR:
12032 {
12033 30256034 do_fastcombor(bmp, sdci, xoffset, yoffset);
12034 }
12035 30256034 break;
12036
12037 case DRAWCHARR:
12038 {
12039 964155 do_drawcharr(bmp, sdci, xoffset, yoffset);
12040 }
12041 964155 break;
12042
12043 case DRAWINTR:
12044 {
12045 176452 do_drawintr(bmp, sdci, xoffset, yoffset);
12046 }
12047 176452 break;
12048
12049 case DRAWSTRINGR:
12050 {
12051 1607511 do_drawstringr(bmp, i, sdci, xoffset, yoffset);
12052 }
12053 1607511 break;
12054
12055 case DRAWSTRINGR2:
12056 {
12057 201739 do_drawstringr2(bmp, i, sdci, xoffset, yoffset);
12058 }
12059 201739 break;
12060
12061 case QUADR:
12062 {
12063 9266 do_drawquadr(bmp, sdci, xoffset, yoffset);
12064 }
12065 9266 break;
12066
12067 case QUAD3DR:
12068 {
12069 do_drawquad3dr(bmp, i, sdci, xoffset, yoffset);
12070 }
12071 break;
12072
12073 case TRIANGLER:
12074 {
12075 do_drawtriangler(bmp, sdci, xoffset, yoffset);
12076 }
12077 break;
12078
12079 case TRIANGLE3DR:
12080 {
12081 do_drawtriangle3dr(bmp, i, sdci, xoffset, yoffset);
12082 }
12083 break;
12084
12085 case POLYGONR:
12086 {
12087 1080 do_polygonr(bmp, i, sdci, xoffset, yoffset);
12088 }
12089 1080 break;
12090
12091
12092 case BITMAPR:
12093 {
12094 937483 do_drawbitmapr(bmp, sdci, xoffset, yoffset);
12095 }
12096 937483 break;
12097
12098 case BITMAPEXR:
12099 {
12100 do_drawbitmapexr(bmp, sdci, xoffset, yoffset);
12101 }
12102 break;
12103
12104 case DRAWLAYERR:
12105 {
12106 4370235 do_drawlayerr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp);
12107 }
12108 4370235 break;
12109
12110 case DRAWSCREENR:
12111 {
12112 50406 do_drawscreenr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp);
12113 }
12114 50406 break;
12115
12116 12431 case BMPRECTR: bmp_do_rectr(bmp, sdci, xoffset, yoffset); break;
12117 case BMPFRAMER: bmp_do_framer(bmp, sdci, xoffset, yoffset); break;
12118 192290 case BMPCIRCLER: bmp_do_circler(bmp, sdci, xoffset, yoffset); break;
12119 case BMPARCR: bmp_do_arcr(bmp, sdci, xoffset, yoffset); break;
12120 502 case BMPELLIPSER: bmp_do_ellipser(bmp, sdci, xoffset, yoffset); break;
12121 144 case BMPLINER: bmp_do_liner(bmp, sdci, xoffset, yoffset); break;
12122 case BMPSPLINER: bmp_do_spliner(bmp, sdci, xoffset, yoffset); break;
12123 80910 case BMPPUTPIXELR: bmp_do_putpixelr(bmp, sdci, xoffset, yoffset); break;
12124 64994 case BMPDRAWTILER: bmp_do_drawtiler(bmp, sdci, xoffset, yoffset); break;
12125 case BMPDRAWTILECLOAKEDR: bmp_do_drawtilecloakedr(bmp, sdci, xoffset, yoffset); break;
12126 11288 case BMPDRAWCOMBOR: bmp_do_drawcombor(bmp, sdci, xoffset, yoffset); break;
12127 case BMPDRAWCOMBOCLOAKEDR: bmp_do_drawcombocloakedr(bmp, sdci, xoffset, yoffset); break;
12128 1982263 case BMPFASTTILER: bmp_do_fasttiler(bmp, sdci, xoffset, yoffset); break;
12129 40175665 case BMPFASTCOMBOR: bmp_do_fastcombor(bmp, sdci, xoffset, yoffset); break;
12130 case BMPDRAWCHARR: bmp_do_drawcharr(bmp, sdci, xoffset, yoffset); break;
12131 case BMPDRAWINTR: bmp_do_drawintr(bmp, sdci, xoffset, yoffset); break;
12132 865 case BMPDRAWSTRINGR: bmp_do_drawstringr(bmp, i, sdci, xoffset, yoffset); break;
12133 45504 case BMPDRAWSTRINGR2: bmp_do_drawstringr2(bmp, i, sdci, xoffset, yoffset); break;
12134 case BMPQUADR: bmp_do_drawquadr(bmp, sdci, xoffset, yoffset); break;
12135 case BMPQUAD3DR: bmp_do_drawquad3dr(bmp, i, sdci, xoffset, yoffset); break;
12136 case BMPTRIANGLER: bmp_do_drawtriangler(bmp, sdci, xoffset, yoffset); break;
12137 case BMPTRIANGLE3DR: bmp_do_drawtriangle3dr(bmp, i, sdci, xoffset, yoffset); break;
12138 case BMPPOLYGONR: bmp_do_polygonr(bmp, i, sdci, xoffset, yoffset); break;
12139 143658 case BMPDRAWLAYERR: do_bmpdrawlayerr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12140 2740 case BMPDRAWSCREENR: do_bmpdrawscreenr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12141 case BMPDRAWSCREENSOLIDR: do_bmpdrawscreen_solidmaskr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12142 case BMPDRAWSCREENSOLID2R: do_bmpdrawscreen_solidr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12143 1024 case BMPDRAWSCREENCOMBOFR: do_bmpdrawscreen_cflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12144 case BMPDRAWSCREENCOMBOIR: do_bmpdrawscreen_ciflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12145 case BMPDRAWSCREENCOMBOTR: do_bmpdrawscreen_ctyper(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12146 2062708 case BMPBLIT: bmp_do_drawbitmapexr(bmp, sdci, xoffset, yoffset); break;
12147 case BMPMODE7: bmp_do_mode7r(bmp, sdci, xoffset, yoffset); break;
12148 113653 case BMPBLITTO: bmp_do_blittor(bmp, sdci, xoffset, yoffset); break;
12149 case TILEBLIT: do_tileblit(bmp, sdci, xoffset, yoffset, false, "TileBlit()"); break;
12150 case COMBOBLIT: do_comboblit(bmp, sdci, xoffset, yoffset, false); break;
12151 case BMPTILEBLIT: do_tileblit(bmp, sdci, xoffset, yoffset, true, "TileBlit()"); break;
12152 case BMPCOMBOBLIT: do_comboblit(bmp, sdci, xoffset, yoffset, true); break;
12153 case READBITMAP: bmp_do_readr(bmp, i, sdci, xoffset, yoffset); break;
12154 case WRITEBITMAP: bmp_do_writer(bmp, i, sdci, xoffset, yoffset); break;
12155 2134433 case CLEARBITMAP: bmp_do_clearr(bmp, sdci, xoffset, yoffset); break;
12156 34749 case BITMAPCLEARTOCOLOR: bmp_do_clearcolorr(bmp, sdci, xoffset, yoffset); break;
12157 43007 case REGENERATEBITMAP: bmp_do_regenr(bmp, sdci, xoffset, yoffset); break;
12158
12159 case BMPDRAWLAYERSOLIDR: do_bmpdrawlayersolidmaskr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12160 case BMPDRAWLAYERCFLAGR: do_bmpdrawlayercflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12161 case BMPDRAWLAYERCTYPER: do_bmpdrawlayerctyper(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12162 case BMPDRAWLAYERCIFLAGR: do_bmpdrawlayerciflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12163 case BMPDRAWLAYERSOLIDITYR: do_bmpdrawlayersolidityr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12164 19821648 case BMPWRITETILE: do_bmpwritetile(bmp, sdci, xoffset, yoffset); break;
12165 case BMPDITHER: do_bmpdither(bmp, sdci, xoffset, yoffset); break;
12166 7323 case BMPREPLCOLOR: do_bmpreplcol(bmp, sdci, xoffset, yoffset); break;
12167 case BMPSHIFTCOLOR: do_bmpshiftcol(bmp, sdci, xoffset, yoffset); break;
12168 906 case BMPMASKDRAW: do_bmpmaskdraw(bmp, sdci, xoffset, yoffset); break;
12169 case BMPMASKBLIT: do_bmpmaskblit(bmp, sdci, xoffset, yoffset); break;
12170
12171 // The following are special cases, in that the target bitmap is fixed (darkscr_bmp).
12172
12173 case DRAWLIGHT_CONE:
12174 {
12175 int32_t cx = sdci[2]/10000 + xoffset;
12176 int32_t cy = sdci[3]/10000 + yoffset;
12177 int32_t dir = sdci[4]/10000;
12178 int32_t length = sdci[5];
12179 int32_t transp_rad = sdci[6];
12180 int32_t dith_rad = sdci[7];
12181 int32_t dith_type = sdci[8];
12182 int32_t dith_arg = sdci[9];
12183
12184 if(length >= 0) length /= 10000;
12185 else length = game->get_light_rad()*2;
12186 if(!length) break;
12187 if(dir < 0) break;
12188 else dir = NORMAL_DIR(dir);
12189 if(transp_rad >= 0) transp_rad /= 10000;
12190 if(dith_rad >= 0) dith_rad /= 10000;
12191 if(dith_type >= 0) dith_type /= 10000;
12192 if(dith_arg >= 0) dith_arg /= 10000;
12193
12194 // Undo the inherit offset applied within the function. xoffset/yoffset handles for us here.
12195 cx += viewport.x;
12196 cy += viewport.y;
12197
12198 doDarkroomCone(cx,cy,length,dir,darkscr_bmp,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
12199 }
12200 break;
12201
12202 case DRAWLIGHT_CIRCLE:
12203 case DRAWLIGHT_SQUARE:
12204 {
12205 int32_t cx = sdci[2]/10000 + xoffset;
12206 int32_t cy = sdci[3]/10000 + yoffset;
12207 int32_t radius = sdci[4];
12208 int32_t transp_rad = sdci[5];
12209 int32_t dith_rad = sdci[6];
12210 int32_t dith_type = sdci[7];
12211 int32_t dith_arg = sdci[8];
12212
12213 if(radius >= 0) radius /= 10000;
12214 else radius = game->get_light_rad();
12215 if(!radius) break;
12216 if(transp_rad >= 0) transp_rad /= 10000;
12217 if(dith_rad >= 0) dith_rad /= 10000;
12218 if(dith_type >= 0) dith_type /= 10000;
12219 if(dith_arg >= 0) dith_arg /= 10000;
12220
12221 // Undo the inherit offset applied within the function. xoffset/yoffset handles for us here.
12222 cx += viewport.x;
12223 cy += viewport.y;
12224
12225 if (sdci[0] == DRAWLIGHT_CIRCLE)
12226 doDarkroomCircle(cx,cy,radius,darkscr_bmp,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
12227 else
12228 doDarkroomSquare(cx,cy,radius,darkscr_bmp,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
12229 }
12230 break;
12231 }
12232 123173242 }
12233
12234
12235 4856981 color_map=trans_table;
12236 418874937 }
12237
12238 16869421 void CScriptDrawingCommands::Clear()
12239 {
12240 16869421 scb.update();
12241 16869421 dirty_layers.clear();
12242
2/2
✓ Branch 0 taken 11519842 times.
✓ Branch 1 taken 5349579 times.
16869421 if(commands.empty())
12243 11519842 return;
12244
12245 //only clear what was used.
12246 5349579 memset((void*)&commands[0], 0, count * sizeof(CScriptDrawingCommandVars));
12247 5349579 count = 0;
12248
12249 5349579 draw_container.Clear();
12250 16869421 }
12251 CScriptDrawingCommands* CScriptDrawingCommands::pop_commands()
12252 {
12253 CScriptDrawingCommands* ret = new CScriptDrawingCommands();
12254 if(commands.empty())
12255 return ret;
12256 ret->push_commands(this, false);
12257
12258 memset((void*)&commands[0], 0, count * sizeof(CScriptDrawingCommandVars));
12259 count = 0;
12260
12261 draw_container.Clear();
12262 return ret;
12263 }
12264 void CScriptDrawingCommands::push_commands(CScriptDrawingCommands* other, bool del)
12265 {
12266 commands.insert(commands.end(), other->commands.begin(), other->commands.end());
12267 count += other->count;
12268 if(del) delete other;
12269 }
12270
12271 vector<int> CScriptDrawingCommands::get_dirty_layers_in_range(int min, int max)
12272 {
12273 vector<int> ret;
12274 for(int layer : dirty_layers)
12275 {
12276 if(layer < min) continue;
12277 if(layer > max) break;
12278 ret.push_back(layer);
12279 }
12280 return ret;
12281 }
12282
12283 170431 void do_script_draws(BITMAP *targetBitmap, mapscr* scr, int32_t xoff, int32_t yoff, bool hideLayer7)
12284 {
12285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170431 times.
170431 if(get_qr(qr_CLASSIC_DRAWING_ORDER))
12286
2/2
✓ Branch 0 taken 168921 times.
✓ Branch 1 taken 1510 times.
171941 if(XOR(scr->flags7&fLAYER2BG, DMaps[cur_dmap].flags&dmfLAYER2BG))
12287 1510 do_primitives(targetBitmap, 2, xoff, yoff);
12288
2/2
✓ Branch 0 taken 163220 times.
✓ Branch 1 taken 7211 times.
170431 if(XOR(scr->flags7&fLAYER3BG, DMaps[cur_dmap].flags&dmfLAYER3BG))
12289 7211 do_primitives(targetBitmap, 3, xoff, yoff);
12290
1/2
✓ Branch 0 taken 170431 times.
✗ Branch 1 not taken.
170431 if(!get_qr(qr_CLASSIC_DRAWING_ORDER))
12291 if(XOR(scr->flags7&fLAYER2BG, DMaps[cur_dmap].flags&dmfLAYER2BG))
12292 do_primitives(targetBitmap, 2, xoff, yoff);
12293 170431 do_primitives(targetBitmap, 0, xoff, yoff);
12294 170431 do_primitives(targetBitmap, 1, xoff, yoff);
12295
2/2
✓ Branch 0 taken 1510 times.
✓ Branch 1 taken 168921 times.
170431 if(!XOR(scr->flags7&fLAYER2BG, DMaps[cur_dmap].flags&dmfLAYER2BG))
12296 168921 do_primitives(targetBitmap, 2, xoff, yoff);
12297
2/2
✓ Branch 0 taken 7211 times.
✓ Branch 1 taken 163220 times.
170431 if(!XOR(scr->flags7&fLAYER3BG, DMaps[cur_dmap].flags&dmfLAYER3BG))
12298 163220 do_primitives(targetBitmap, 3, xoff, yoff);
12299 170431 do_primitives(targetBitmap, 4, xoff, yoff);
12300 170431 do_primitives(targetBitmap, 5, xoff, yoff);
12301 170431 do_primitives(targetBitmap, 6, xoff, yoff);
12302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170431 times.
170431 if(!hideLayer7) do_primitives(targetBitmap, 7, xoff, yoff);
12303 170431 }
12304